Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    May 2009
    Location
    Glastonbury, UK
    Posts
    53
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How to separate email addresses and mail to them.

    Hi there,
    I am trying to write a script that will get all data from mysql dtabase where user_actived = 0.
    I then want my script to send an email to those people.
    The problem is when I echo what it has returned i get something like this:
    somebody@somehost.comsomebodyelse@thishost.co.uk
    How would i seperate the email adddresses and then mail an email to each of them.
    Thanks
    Noisyscanner

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Can you post your php code on how you are getting the results? Is likely just a html issue.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New Coder
    Join Date
    May 2009
    Location
    Glastonbury, UK
    Posts
    53
    Thanks
    1
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php
    mysql_connect
    ("localhost""myusername""mypassword") or die(mysql_error());
    mysql_select_db("mydatabase") or die(mysql_error());
    $select_game mysql_query("SELECT * FROM users WHERE user_activated = '0'");
    while(
    $row mysql_fetch_array$select_game )) {
    echo(
    $row['user_email']);
    $message 
    "Thank you for registering an account with Universalgames.\n
    You have not yet activated your account, so you will not be able to log in to Universalgames.\n
    Please activate it by clicking below:
    http://mysite.com/activate.php
    _____________________________________________
    This is an automated response. PLEASE DO NOT REPLY.
    "
    ;

        
    mail($row['user_email'] , "Universalgames account activation"$message,
        
    "From: \"Universalgames\" <accounts@$host>\r\n" .
         
    "X-Mailer: PHP/" phpversion());
    }
    ?>
    Last edited by noisyscanner; 05-31-2009 at 12:41 PM.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Yeah see this is all you are doing
    PHP Code:
    echo($row['user_email']); 
    just change that to this
    PHP Code:
    echo $row['user_email'].'<br>'
    They are already "separated". I suggest you remove your personal information from your post.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    noisyscanner (05-31-2009)

  • #5
    New Coder
    Join Date
    May 2009
    Location
    Glastonbury, UK
    Posts
    53
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks now it is all echoed on a new line.
    Would my mail function now work?

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    It should have already been working. As the emails were different each time the mail function was called. If its not working then there is something wrong with your server.

    Add this after <?php
    PHP Code:
    ini_set('display_errors','1');
    error_reporting(E_ALL); 
    Let us know what you get and you STILL didn't remove your username and password from your post.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #7
    New Coder
    Join Date
    May 2009
    Location
    Glastonbury, UK
    Posts
    53
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ok thanks all is working now!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •