I'm sending a simple email using PHP mail() function in HTML content type. It works fine on every email, except Outlook, where whole content of my mail is transferred into an attachment with .dat extension. Why is it happening? Is there a way to fix it or to workaround?
I haven't found an explanation anywhere, why is it happening in so simple case. (Outlook settings are set to open emails as HTML and HTML emails sent from other websites looks fine too)
mail('myMail@gmail.com', "Testing", "First line<br>Second line <b>bolded text</b>", "From: myWebsite@mail.com\nContent-Type:".' text/html;charset="UTF-8"'."\nContent-Transfer-Encoding: 8bit");
Note that "extra headers should be separated with a CRLF (\\r\\n)" cf https://www.php.net/manual/en/function.mail.php
Try adding the MIME flag and see if it then works for you:
$headers = "From: myWebsite@mail.com \r\n".
"Content-type: text/html; charset=UTF-8 \r\n".
"Content-Transfer-Encoding: 8bit \r\n".
"MIME-Version: 1.0";
mail('myMail@gmail.com', "Testing", "First line<br>Second line <b>bolded text</b>", $headers);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.