0 レビュー
2 回答
PHPプレーンテキストとHTMLを含むメールを送信する
次のメールヘッダーがあります:
$random_hash = md5(date('r', time()));
$headers = array ('From' => $from,
'To' => $to,
'Return-Path' => '[email protected]',
'Subject' => $subject,
'Content-Type'=>'multipart/alternative');
1つのメールで2つのバージョンのメールを送信したい。 1つのテキストと1つのhtml。
だから私はこれをしました:
ob_start(); ?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Copy and paste: http://example.com/app_dl.php?app_id=<?php echo $_GET[app_id]; ?> to download your $app_name app \r\n
Want to get tons more hot apps for free! anywhere anytime? Download our app on http://example.com \r\n
example.com team;
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<p><a href='http://example.com/app_dl.php?app_id=<?php echo $_GET[app_id]; ?>'>Click Here</a> to download your <?php echo $app_name_app; ?></p>
<p>Want to get tons more hot apps for free! anywhere anytime? Download our app on <a href='http://example.com'>example.com</a></p>
<br/>
<p>example.com team</p>";
<?php
$bodyHTML =ob_get_clean();
しかし、うまく機能していないようです。なぜだろうか!?!?
わからない
0
レビュー
答え :
解決策:
multipart/alternative
メッセージを作成するには、 boundary
を指定する必要があります。各部分をそのboundaryで区切ります。優れたboundary文字列は、 sha1(uniqid())
によって生成されたランダムな文字列など、メッセージ部分自体で発生する可能性が非常に低いものです。例:
MIME-バージョン:1.0
コンテンツタイプ:multipart/alternative; boundary = c4d5d00c4725d9ed0b3c8b
--c4d5d00c4725d9ed0b3c8b
コンテンツタイプ:テキスト/プレーン; charset = "iso-8859-1"
Content-Transfer-Encoding:7ビット
パート1
--c4d5d00c4725d9ed0b3c8b
コンテンツタイプ:text / html; charset = "iso-8859-1"
Content-Transfer-Encoding:7ビット
パート2
--c4d5d00c4725d9ed0b3c8b--
これは、 RFC 2046、セクション5.1.4で指定されています。
わからない
0
レビュー
答え :
解決策:
\ r\nの代わりにPHP_EOLを使用しても機能するようです。例:
$headers = "Content-type: text/html; charset=UTF8" . PHP_EOL;
わからない
同様の質問
私たちのウェブサイトで同様の質問で答えを見つけてください。