•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 330,320 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,736 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
This function distributes mail to a mailing list, out of an array. Wether the array is plundered from a database, a file, or from the code, the function only takes a prepared one. Also, this function is only good for HTML messages.
The array's syntax is to be:
In-order to insert the name into the email, just use ((name)), as it will be replaced with the array-given value.
$from is for the email you want to be replied to.
If all recipents were mailed successfully, the function returns true, else it returns the errors.
You can use it like so:
If you want, I can make another function with a lot more variables to send. Just request it via comment, please.
The array's syntax is to be:
array("recipent's name"=>"email","recipent's name"=>"email","recipent's name"=>"email");In-order to insert the name into the email, just use ((name)), as it will be replaced with the array-given value.
$from is for the email you want to be replied to.
If all recipents were mailed successfully, the function returns true, else it returns the errors.
You can use it like so:
if($handle=@mail_list($array,$subject,$message,$from)) {
#...#
}
else {
echo $handle;
} Last edited : Sep 21st, 2007.
function mail_list($ml_array,$subject,$message,$from) { $i=0; foreach($ml_array as $name => $email) { $message = str_replace("((name))",$name,$message); if(@mail($email,$subject,$message,"Content-type: Text/HTML;From:".$from.";Reply-To:".$from.";")) { $i++; } else { $errors[] = "Failed to send email to ".$email."."; } } if($i==sizeof($ml_array)) return true; else return implode("<br/>",$errors); }
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)