onlyican Posted May 14, 2010 Share Posted May 14, 2010 Hi We have recently moved servers and now I have noticed that the mail is not sending basic email is as follows $sendEmailTo = "[email protected]"; $MailSubject = "Contact Information"; $MailHeaders = ""; $MailBodyTxt = "This is the body"; $MailHeaders .= 'MIME-Version:1.0'."\r\n"; $MailHeaders .= 'Content-type: text/html; charset=iso-8859-1'."\r\n"; $MailHeaders .= 'To: [email protected]'."\r\n"; $MailHeaders .= 'From: [email protected]'."\r\n"; $MailHeaders .= 'Reply-To: Jamie <[email protected]>'."\r\n"; if(mail($sendEmailTo, $MailSubject, $MailBodyTxt, $MailHeaders)){ echo "Mail Sent"; }else{ echo "Error"; } Above fails, if I comment out the header line 'From:.... then it fails, any suggestions or ideas (PHP V 5.2.12, any other info required, give us a shout) Quote Link to comment https://forums.phpfreaks.com/topic/201721-mail-fails-with-from-header/ Share on other sites More sharing options...
Muddy_Funster Posted May 14, 2010 Share Posted May 14, 2010 What's the actual error? And have you considered that the new servers SMTP setup could be at fault? Quote Link to comment https://forums.phpfreaks.com/topic/201721-mail-fails-with-from-header/#findComment-1058151 Share on other sites More sharing options...
onlyican Posted May 14, 2010 Author Share Posted May 14, 2010 I can not see an error, as you are aware, PHP Mail() error handling is less than perfect. I have thought it could be a server issue, just wanted to check before I have a go at the hosting company. Quote Link to comment https://forums.phpfreaks.com/topic/201721-mail-fails-with-from-header/#findComment-1058152 Share on other sites More sharing options...
cags Posted May 14, 2010 Share Posted May 14, 2010 Did you make a typo in the original question? You state in the title that it fails with 'From' header, you then go on to state that it fails if you take it out... Assuming it works with it commented out, does it actually 'Fail' i.e. output "Error" or are you just not receiving the e-mail and it actually outputs "Mail Sent"? Quote Link to comment https://forums.phpfreaks.com/topic/201721-mail-fails-with-from-header/#findComment-1058153 Share on other sites More sharing options...
onlyican Posted May 14, 2010 Author Share Posted May 14, 2010 Soz, if I remove the line 'From:..., then mail() will return true, (Mail sent) Without that 1 line, everything works fine If I leave the line it, it returns false, (no mail sent) Quote Link to comment https://forums.phpfreaks.com/topic/201721-mail-fails-with-from-header/#findComment-1058156 Share on other sites More sharing options...
Muddy_Funster Posted May 14, 2010 Share Posted May 14, 2010 I dont see any malformation in the header From: line (although I will assume the address is an exepler) perticularly if the Reply-To is working without a problem. What seems most likely is that the SMTP server has MX record send restrictions (i.e. if the IP address the mail is coming from does not resolve to the same global IP address as the domain MX record used in the From header it will treat it as spam.) have you tried setting error_reporting(E_ALL) at the top of the page to see if it will show anything new? Quote Link to comment https://forums.phpfreaks.com/topic/201721-mail-fails-with-from-header/#findComment-1058159 Share on other sites More sharing options...
onlyican Posted May 14, 2010 Author Share Posted May 14, 2010 Problem solved, there was an issue with the server handling the \r This has now been resolved, if you suffer with this issue, check that with your hosting company, they need to upload a fix. Quote Link to comment https://forums.phpfreaks.com/topic/201721-mail-fails-with-from-header/#findComment-1058245 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.