Jump to content

mail() fails with FROM: header


onlyican

Recommended Posts

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)

Link to comment
https://forums.phpfreaks.com/topic/201721-mail-fails-with-from-header/
Share on other sites

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"?

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.