PHP - how to sent mail to more that 1 email at the same time

Asked By Olusegun A. on 14-Jul-10 06:21 AM
Hello friends,

I know hot to code my form to send mail to the only one enter email, but when i try to enter more thatn one email and seperate them with comma(,) the mail did not go, how can i do it.

regards
Ken Fitzpatrick replied to Olusegun A. on 14-Jul-10 06:34 AM

Try a semi-colon ';'


Ken

Anoop S replied to Olusegun A. on 14-Jul-10 06:46 AM

create an array of the email addresses to send to and then run through that array using an email function.

like this way

function emailFolks($email, $name, $message){
echo "<p>Thank you, <strong>".$name."</strong>, for your message!</p>";
echo "<p>Your e-mail address is: <strong>".$email."</strong>.</p>";
echo "<p>Your message was:<br/>";
echo $message."</p>";
//start building the mail string
$msg = "Name: ".$name."\n";
$msg .= "E-Mail: ".$email."\n";
$msg .= "Message: ".$message."\n";
//set up the mail
$recipient = "$email";
$subject = "Form Submission Results";
$mailheaders = "From:Me <me@mydomain.com> \n";
$mailheaders .= "Reply-To: ".$_POST["email"];
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
}



Gayathri S replied to Olusegun A. on 15-Jul-10 06:17 AM
You can use the explode function and run a for loop over the resulting array to send mail to multiple emails.

An example would be:
$value=$_POST['email']; // this is the comma separated list of email addresses
$emails=explode(",",$value);
foreach($emails as $email)
{
  //now you can use $email to send email to everyone in the list
  mail(...);
}

Olusegun A. replied to Olusegun A. on 18-Jul-10 10:37 AM

thank you all for contributing to my request, i really appreciated the assistance.

regards,

adsegzy