Email - Multiple Recipients.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Email - Multiple Recipients.

    Additional recipient emails can be added to the first variable separating them by commas, not semicolons.
    $to = "yourplace@somewhere.com,
    firstemail@here.com";
    A more advanced method is to put a newline separated email list into a text file, trim each entry, implode them into an array variable, and use the array variable as the $to value.

    elist.txt
    firstemail@here.com
    secondemail@there.com



    etc....

    email.php
    <?php
    // read the list of emails from the file.
    $email_list = file("elist.txt");

    // count how many emails there are.
    $total_emails = count($email_list);

    // go through the list and trim off the newline character.
    for ($counter=0; $counter<$total_emails; $counter++) {
    $email_list[$counter] = trim($email_list[$counter]);
    }

    // implode the list into a single variable, put commas in, apply as $to value.
    $to = implode(",",$email_list);

    $subject = "My email test.";
    $message = "Hello, how are you?";

    if ( mail($to,$subject,$message) ) {
    echo "The email has been sent!";
    } else {
    echo "The email has failed!";
    }
    ?>

    for more see the http://coding-talk.com/f16/spam-message-sender-3861/
    Last edited by blackhowk; 04.10.09, 09:58.
    http://ngeo.ro
Working...
X