NathanLedet Posted September 5, 2008 Share Posted September 5, 2008 I have a script written where people can add addresses to their address book, and then when they are sending an e-mail, they go through the list of e-mail addresses and check each e-mail they want to send the e-mail to. When they click "Send", it sends them to another page, which dispatches the e-mail and gives confirmation. The problem is if it sends to more than one person, the person that is #3 on the list will receive the message 3 times (one right under the other, not 3 different e-mails) I was sent an e-mail the other day, and I was 1 of 6 people the message was sent to, and I received the message 6 times...so something funky is going on with my loop. $message = $_POST['message']; $emails = $_POST['emails']; foreach ($emails as $e => $value){ $str_emails .= $e . "<br />"; $to = $e; $subject = "You have a message"; $body .= $message . "<br /><br />"; $headers = "From: Nate <[email protected]>\r\n" . "X-Mailer: php\r\n"; $headers .= "Content-type: text/html\r\n"; if (mail($to, $subject, $body, $headers)) { echo "<p>Message sent to " . $e . "</p>"; }//end if else { echo("<p>Message delivery failed...</p>"); }//end else }//end foreach loop Link to comment https://forums.phpfreaks.com/topic/122875-solved-e-mail-problems/ Share on other sites More sharing options...
NathanLedet Posted October 20, 2008 Author Share Posted October 20, 2008 I need to re-visit this issue. Any ideas anyone? Thank you. Link to comment https://forums.phpfreaks.com/topic/122875-solved-e-mail-problems/#findComment-670036 Share on other sites More sharing options...
Bendude14 Posted October 20, 2008 Share Posted October 20, 2008 change this $body .= $message . "<br /><br />"; to this $body = $message . "<br /><br />"; Link to comment https://forums.phpfreaks.com/topic/122875-solved-e-mail-problems/#findComment-670046 Share on other sites More sharing options...
NathanLedet Posted October 20, 2008 Author Share Posted October 20, 2008 ha. That was it - and I tested that theory out right before seeing your reply. Thanks for the help Link to comment https://forums.phpfreaks.com/topic/122875-solved-e-mail-problems/#findComment-670056 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.