Reputation: 12170
I've been trying out some php codes and I cannot able to send mail through the following code. I've sent some days before but now the mail()
function returns true but the mail is not in the recipient's inbox. Here's the code:
$to = "[email protected]";
$subject = "Testing Emails";
$emailBody = "Hello";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: Test <[email protected]>" . "\r\n";
$headers .= "Reply-To: [email protected]"."\r\n";
$mail = mail($to,$subject,$emailBody,$headers);
if($mail){
echo 'Successfully sent';
} else {
echo 'Failed to send';
}
Note: I've replaced all the to
address with an original address.
Upvotes: 0
Views: 653
Reputation: 33439
From the PHP mail function page
Note:
If messages are not received, try using a LF (\n) only.
Some Unix mail transfer agents (most notably » qmail) replace LF by CRLF
automatically (which leads to doubling CR if CRLF is used).
This should be a last resort, as it does not comply with » RFC 2822.
Upvotes: 1