_giles_ Posted May 16, 2007 Share Posted May 16, 2007 Hi there, I’ve written a simple mailout script. If appears to work fine for some people, appears to fail with others. The fails are with clients inside Uni’s and Corps ... so I’m wondering if I’m getting spam filtered or something alike. I include my code below. I would greatly appreciate any comments on how I may improve it. Thanks Giles $to = $email; $subject = "the subject"; $from = "my outgoing address"; $headers = "From: $from"; $headers.= "Content-Type: text/html; charset=ISO-8859-1 "; $headers .= "MIME-Version: 1.0 "; $body = "Dear " . $firstname . " " . $surname . ", my message goes here " . "Your username is : " . $username . " " . "Your password is : " . $password; this is a comment reinserted from the author /*notice there aren't any \r\n after the second two header additions. This is what made this version work correctly*/ mail($to,$subject,$body,$headers); Quote Link to comment https://forums.phpfreaks.com/topic/51598-problems-with-sending-email/ Share on other sites More sharing options...
phast1 Posted May 16, 2007 Share Posted May 16, 2007 There are many things that can cause a mail server to reject an e-mail, but improperly formed headers will definitely upset many mail servers.. I see that your code has a comment about the \n codes being removed from the header lines for some reason, but this is definitely not good.. Without the \n codes, your headers will all be on one line and this would not be valid, so I would recommend fixing this first.. Quote Link to comment https://forums.phpfreaks.com/topic/51598-problems-with-sending-email/#findComment-254195 Share on other sites More sharing options...
neel_basu Posted May 16, 2007 Share Posted May 16, 2007 you need to separate those by \r\n not by \n. Quote Link to comment https://forums.phpfreaks.com/topic/51598-problems-with-sending-email/#findComment-254201 Share on other sites More sharing options...
phast1 Posted May 16, 2007 Share Posted May 16, 2007 What does \are do? I've always used \n without problems and have also seen \r\n being used, but \are is a new one for me.. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/51598-problems-with-sending-email/#findComment-254209 Share on other sites More sharing options...
neel_basu Posted May 16, 2007 Share Posted May 16, 2007 its not \are its \r Quote Link to comment https://forums.phpfreaks.com/topic/51598-problems-with-sending-email/#findComment-254220 Share on other sites More sharing options...
phast1 Posted May 16, 2007 Share Posted May 16, 2007 lol, ok, it looks like the forum software is screwing up our posts.. For some reason it won't allow the single letter R (comes after Q, lol) and keeps converting it to 'are' Quote Link to comment https://forums.phpfreaks.com/topic/51598-problems-with-sending-email/#findComment-254252 Share on other sites More sharing options...
neel_basu Posted May 16, 2007 Share Posted May 16, 2007 Forum Software ???????????????? What is it ?? Quote Link to comment https://forums.phpfreaks.com/topic/51598-problems-with-sending-email/#findComment-254255 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.