send multiple emails

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alexmaster_2004
Forum Commoner
Posts: 35
Joined: Wed Sep 14, 2005 8:44 am

send multiple emails

Post by alexmaster_2004 »

Hi There
i want to know how to send an email to multiple users at once.
Hope anyone can help
Thanks
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Code: Select all

function MAIL_NVLP($fromname, $fromaddress, $toname, $toaddress, $subject, $message){
   // Copyright ? 2005 ECRIA LLC, http://www.ECRIA.com
   // Please use or modify for any purpose but leave this notice unchanged.
   $headers  = "MIME-Version: 1.0\n";
   $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
   $headers .= "X-Priority: 3\n";
   $headers .= "X-MSMail-Priority: Normal\n";
   $headers .= "X-Mailer: php\n";
   $headers .= "From: \"".$fromname."\" <".$fromaddress.">\n";
   return mail($toaddress, $subject, $message, $headers);
}

$recipients = array("John Eaton" => "johneaton@nancy.com", "MArk Jones" => "flappiwap@johneaton.com", "FOOBAR" => "foo@bar.com");
foreach($recipients as $key => $val){
    MAIL_NVLP("Your Name", "you@yourdomain.com", $key, $val, "Subject", "message");
}
alexmaster_2004
Forum Commoner
Posts: 35
Joined: Wed Sep 14, 2005 8:44 am

Post by alexmaster_2004 »

Hi
Thanks for reply. but i think you miss understand me.
what i mean is i want to excute the mail function just one time.
mean that the "$toaddres" variable must contain all the emai addresses
and when i use this statement: mail($toaddress, $subject, $message, $headers)
then the email shoild go to all emails in the $toaddress.
i hope that this is clear for you.
Thanks again
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

comma separate the addresses.
Post Reply