DarkPrince2005 Posted November 14, 2007 Share Posted November 14, 2007 Can somebody please help!!! How would I change the attached code to send to more than one email? <?php ini_set('display_errors','On'); error_reporting(E_ALL); $to = "me@somewhere.com"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $from = "From: "; if (mail($to, $subject, $body, $from)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> Quote Link to comment Share on other sites More sharing options...
aschk Posted November 14, 2007 Share Posted November 14, 2007 $arrayOfEmails = array("my@domain.com","your@domain.com","someone@domain.com"); $totalNumber = count($arrayOfEmails); for($i=0; $i<=$totalNumber; $i++){ if (mail($arrayOfEmails[$i], $subject, $body, $from)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } } Make sure to define $subject,$body,$from (as you did before). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.