ニュースレターのテキスト バージョンと HTML バージョンの 1 つの領域を含むマルチパート MIME 電子メールをセットアップしました。私のiPhoneを除いて、すべて正常に動作します。最初にテキスト バージョンが表示され、次に HTML バージョンが表示されます。しかし、私には理由がわかりません... :-/
PHPは次のとおりです。
$to = $_POST['email'];
$subject = 'Test';
$bound_text = 'boundary42';
$headers = "From: sender@sender.net\r\n";
$headers .= "MIME-Version: 1.0\r\n"
. "Content-Type: multipart/mixed; boundary=\"$bound_text\"";
$message = file_get_contents('mime.file');
mail($to, $subject, $message, $headers);
ファイルの内容:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=boundary42
This is a message with multiple parts in MIME format.
--boundary42
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Text goes here
--boundary42
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="margin:0;padding:0;font-family: arial, 'Arial';">
html goes here
</body>
</html>
--boundary42--