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 = "[email protected]"; $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>"); } ?> Link to comment https://forums.phpfreaks.com/topic/77298-solved-email/ Share on other sites More sharing options...
aschk Posted November 14, 2007 Share Posted November 14, 2007 $arrayOfEmails = array("[email protected]","[email protected]","[email protected]"); $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). Link to comment https://forums.phpfreaks.com/topic/77298-solved-email/#findComment-391344 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.