I'm sending mails using the PHP mail() function. The mail headers is not working properly.
$charset = mb_detect_encoding($message);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: '.$from . "\r\n";
$headers .= 'Content-type: text/html; charset='.$charset . "\r\n";
$headers .= 'Reply-To: '.$from . "\r\n";
$headers .= 'X-Mailer: php';
In the above code, the only first line is parsed and the later 4 lines are showing in the message body. "From" was not set.
$charset = mb_detect_encoding($message);
$headers = 'From: '.$from . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset='.$charset . "\r\n";
$headers .= 'Reply-To: '.$from . "\r\n";
$headers .= 'X-Mailer: php';
In the above code, "From" and "MIME" lines are parsed correctly, but the later 3 lines are showing in the message body.
GMail is receiving it correctly.