It turns out the key is a type of encoding. Instead:
Content-Type: text/plain; charset="iso-8859-1"
I needed to use:
Content-Type: text/plain; charset=us-ascii
This may depend on how detailed you save the PHP file in your text editor. I did not study it, but the iconv function in PHP may also have brought me joy. Therefore, I believe that this part is very sensitive.
Here is the best example code snippet that shows the whole thing:
$notice_text = "This is a multi-part message in MIME format."; $plain_text = "This is a plain text email.\r\nIt is very cool."; $html_text = "<html><body>This is an <b style='color:purple'>HTML</b> text email.\r\nIt is very cool.</body></html>"; $semi_rand = md5(time()); $mime_boundary = "==MULTIPART_BOUNDARY_$semi_rand"; $mime_boundary_header = chr(34) . $mime_boundary . chr(34); $to = "Me < foo@gmail.com >"; $from = "Me.com < me@me.com >"; $subject = "My Email"; $body = "$notice_text --$mime_boundary Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit $plain_text --$mime_boundary Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit $html_text --$mime_boundary--"; if (@mail($to, $subject, $body, "From: " . $from . "\n" . "MIME-Version: 1.0\n" . "Content-Type: multipart/alternative;\n" . " boundary=" . $mime_boundary_header)) echo "Email sent successfully."; else echo "Email NOT sent successfully!"; exit;
Kevin
Kevinm
source share