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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    mail($to, $subject, $message, $headers)

    Another problem.
    I'm creating a .php auto sender mail to diferent persons in there Birthday.

    here is the query:

    $data =date("m", time());
    $data1=date("d",time());


    mysql_select_db( $db, $link ) or die ( "Couldn't open $db: ".mysql_error() );
    $result = mysql_query( "SELECT Nome, Email FROM funcionarios where extract(day from Data_de_Nascimento)='$data1' and extract(month from Data_de_Nascimento)='$data' order by Data_de_Nascimento" );

    then i make a while to capture the mail and the name:

    while ( $row = mysql_fetch_array( $result ) )
    {
    $to .= $row[Email] . ',';
    rtrim($to, ',');
    $na .= $row[Nome] . ',';
    rtrim($na, ',');
    }



    then i try to send it like this:

    $sub="Feliz aniversario";
    ini_set('SMTP', 'mail.clix.pt');
    $subject = "$sub";
    $message = "A fastforward $na ................................ Feliz aniversario";
    $headers = 'From: bitlo@clix.pt' . "\r\n" .
    'Reply-To: bitlo@clix.pt' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

    mail($to, $subject, $message, $headers);

    its sends to all the mail capture in the database, the problem is that in all mails it sends all the names, and i nedd to put in the mail the equal name.

    remind the names are capture from the database.

    Can someone Help.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Two options. The first is to use blind carbons for each person on the list, and just send the one email to yourself with the blinds. The other option is to send a single mail for each entry in you're database. This approach is... not exactly what you want, depending on you're records size.
    The best approach is to cron a job to create a temporary table that contains all the people who need to be emailed. Then, cron another script to go through this table every minute or so, and extract say 10 names at a time. Then email them. Then delete them. This should keep you're load under control.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Ok thanks for reply.
    But that is not the issue, i need to put in the message the right name.
    Now it send the mails to the people o makes birthday, supose it make 50 people, it sends to the 50 people but in the message it go's 50 name, and i need to put only one name to one mail.
    Im trying with for each but i dont get it right
    Last edited by Tulungo; 01-22-2010 at 05:27 PM.

  • #4
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Well, show the foreach to get help with it.
    Are you a Help Vampire?

  • #5
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,389
    Thanks
    13
    Thanked 353 Times in 349 Posts
    Quote Originally Posted by Tulungo View Post
    But that is not the issue, i need to put in the message the right name.
    Now it send the mails to the people o makes birthday, supose it make 50 people, it sends to the 50 people but in the message it go's 50 name, and i need to put only one name to one mail.
    the SwiftMailer email library has a plugin that allows you to send personalized emails in a batch.


  •  

    Posting Permissions

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