Home Apache PHP Ubuntu MySQL Linux HTML Win CSS Perl Javascript Rants Retro
 
Print This Page
Date Posted: Sunday 07th of February 2010 | Category: PHP
Send Plain Text Email To Multiple Recipients Using PHP
To send a plain text email in PHP, to multiple recipients use the following code below:

<?php
$recipients = array($email_address1, $email_address2);
$subject = "Test e-mail using PHP to Multiple Recipients";
$message = "This is a test e-mail using PHP";
$from = "$email_address";
$headers = "From: $from";

foreach ($recipients as $recipient) {
if ( mail($recipient,$subject,$message,$headers) )
echo "Mail Sent to $recipient.";
}
?>