Gainax Posted July 22, 2009 Share Posted July 22, 2009 Hi I have a form which sends out an email. I'm trying to send it to muliple people. The following is my code: $to = "[email protected]"; $subject = "New Applicants submit"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; /* headers adicionais */ $headers .= "To: Jim <[email protected]>, Ted <[email protected]>\r\n"; $headers .= "From: Web <[email protected]>\r\n"; mail($to, $subject, $msg, $headers); This all works fine when I put the email addresses of some of my colleagues (using Gmail). But If I try putting any other email, those who use Outlook, no-one receives the emails. Is there anything wrong with my form? Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/ Share on other sites More sharing options...
WolfRage Posted July 22, 2009 Share Posted July 22, 2009 You need to add the additional recipients to the $to section adding them to the headers is not enough that just notifies the others as to who the email was sent. Also if it works on a gmail account then it is fine, sounds like you have the wrong emails or the outlook users do not have there email client setup right, or it is filtering it as spam, be sure to check junk folder in outlook. Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880375 Share on other sites More sharing options...
Gainax Posted July 22, 2009 Author Share Posted July 22, 2009 $to = "[email protected], [email protected], [email protected]"; Will this do? Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880387 Share on other sites More sharing options...
jcrew Posted July 22, 2009 Share Posted July 22, 2009 $to = "[email protected], [email protected], [email protected]"; Will this do? Yes. Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880394 Share on other sites More sharing options...
ignace Posted July 22, 2009 Share Posted July 22, 2009 $to = "[email protected], [email protected], [email protected]"; Will this do? Yes. Their has been a post before who had problems sending his mail to multiple recipients using $to. Altough 'to' can accept multiple recipients it's probably better - for spam sake's - to only add 1 'to' recipient and split all others over cc and bcc Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880407 Share on other sites More sharing options...
jcrew Posted July 22, 2009 Share Posted July 22, 2009 $to = "[email protected], [email protected], [email protected]"; Will this do? Yes. Their has been a post before who had problems sending his mail to multiple recipients using $to. Altough 'to' can accept multiple recipients it's probably better - for spam sake's - to only add 1 'to' recipient and split all others over cc and bcc That's interesting! Definitely keeping that in mind. (Usually, in the far few in between cases where I use mail(), I just hold a while() statement and send each person an individual email). Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880411 Share on other sites More sharing options...
WolfRage Posted July 22, 2009 Share Posted July 22, 2009 I concur with Jcrew, as it has been my experince that if I have more than 3 recipients then the messages need to be sent as seperate emails. Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880421 Share on other sites More sharing options...
Gainax Posted July 22, 2009 Author Share Posted July 22, 2009 So something along the lines of: $to = "[email protected]"; $subject = "New Applicants submit"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; /* headers adicionais */ $headers .= "From: Web <[email protected]>\r\n"; $headers . = "Cc: jim <[email protected]>, ted <[email protected]>"; mail($to, $subject, $msg, $headers); Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880427 Share on other sites More sharing options...
Gainax Posted July 22, 2009 Author Share Posted July 22, 2009 I concur with Jcrew, as it has been my experince that if I have more than 3 recipients then the messages need to be sent as seperate emails. How would I do this? Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880431 Share on other sites More sharing options...
WolfRage Posted July 22, 2009 Share Posted July 22, 2009 <?php $to=explode(',',$to); foreach($to as $recipient) { mail($recipient,$subject,$message); } ?> Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880434 Share on other sites More sharing options...
Gainax Posted July 22, 2009 Author Share Posted July 22, 2009 Will I still have the following code? $to = "[email protected], [email protected], [email protected]"; Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880437 Share on other sites More sharing options...
WolfRage Posted July 22, 2009 Share Posted July 22, 2009 Yes but you should use single quotes instead of double, just because double are not necessary and add some extra processing time. Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880439 Share on other sites More sharing options...
Gainax Posted July 22, 2009 Author Share Posted July 22, 2009 What about the headers? The email gets sent as HTML. Can I still have the $headers in the mail()? Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880444 Share on other sites More sharing options...
Gainax Posted July 22, 2009 Author Share Posted July 22, 2009 My code is : $to = '[email protected], [email protected], [email protected]'; $subject = "New Applicants submit"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "To: Ted <[email protected]>, bob <[email protected]>, jim <[email protected]>\r\n"; $headers .= "From: Website <[email protected]>\r\n"; $to = explode(',',$to); foreach($to as $recipient) { mail($recipient,$subject,$msg,$headers); } Should this work? Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880464 Share on other sites More sharing options...
WolfRage Posted July 22, 2009 Share Posted July 22, 2009 Yes but you should also get rid of the space between recipients on the $to var. Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880478 Share on other sites More sharing options...
Gainax Posted July 22, 2009 Author Share Posted July 22, 2009 Ok thanks. I'll see If those who should get the emails do in fact get them Thanks Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880488 Share on other sites More sharing options...
ignace Posted July 22, 2009 Share Posted July 22, 2009 I concur with Jcrew, as it has been my experince that if I have more than 3 recipients then the messages need to be sent as seperate emails. Possibly even personalising the e-mail. Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-880624 Share on other sites More sharing options...
Gainax Posted July 23, 2009 Author Share Posted July 23, 2009 Ok I have the following code now, and only I can get the emails: $to = '[email protected],[email protected],[email protected]'; $subject = "Form Submit"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "To: Client1 <[email protected]>,Client2 <[email protected]>,Me <[email protected]>\r\n"; $headers .= "From: Website <[email protected]>\r\n"; $to = explode(',',$to); foreach($to as $recipient) { if (mail($recipient, $subject, $message, $headers)) { header('Location: thankyou.php'); } else { echo("<p>Message delivery failed...</p>"); } } I get the emails fine. But the other 2 email addresses don not receive anything. Is there anything wrong with my code? Thanks Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-881041 Share on other sites More sharing options...
ignace Posted July 23, 2009 Share Posted July 23, 2009 Ok I have the following code now, and only I can get the emails: $to = '[email protected],[email protected],[email protected]'; $subject = "Form Submit"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "To: Client1 <[email protected]>,Client2 <[email protected]>,Me <[email protected]>\r\n"; $headers .= "From: Website <[email protected]>\r\n"; $to = explode(',',$to); foreach($to as $recipient) { if (mail($recipient, $subject, $message, $headers)) { header('Location: thankyou.php'); } else { echo("<p>Message delivery failed...</p>"); } } I get the emails fine. But the other 2 email addresses don not receive anything. Is there anything wrong with my code? Thanks There is nothing wrong with your code. It's probably the SPAM filters that stop your e-mail from being received either send each e-mail individually or only add one $to and add the others to $cc or $bcc Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-881050 Share on other sites More sharing options...
Gainax Posted July 23, 2009 Author Share Posted July 23, 2009 Ok I now have this: $to = '[email protected]'; $subject = "Form Submit"; $headers .= "From: Website <[email protected]>\r\n"; $headers .= "To: [email protected]\r\n"; $headers .= "Cc: [email protected]\r\n"; $headers .= "Bcc: [email protected]\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; if (mail($to, $subject, $message, $headers)) { header('Location: thankyou.php'); } else { echo("<p>Message delivery failed...</p>"); } Does this look ok? Link to comment https://forums.phpfreaks.com/topic/166982-php-form-not-receiving-email/#findComment-881061 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.