に送信します。 ただし、コード内のmail()関数の最初の呼び出しにのみ送信します。すなわち第1の反復は機能し、第2の反復は機能しない。その電子メールアドレスではなく、私はそれを動作させるので問題が発生します。助言がありますか?メール機能だけで、私は私に、別のアドレスに電子メールを送り、いくつかのコードを持っている最初のインスタンス
<?PHP
$to = '[email protected]';
$subject = 'test title 1';
$message = '
<html>
<head>
<title>Test 1</title>
</head>
<body>
<h1>test 1</h1>
<p>test 1</p>
</body>
</html>
';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: Test <[email protected]>';
mail($to, $subject, $message, implode("\r\n", $headers));
$to = '[email protected]';
$subject = 'test title 2';
$message = '
<html>
<head>
<title>Test 2</title>
</head>
<body>
<h1>test 2</h1>
<p>test 2</p>
</body>
</html>
';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: Test <[email protected]>';
mail($to, $subject, $message, implode("\r\n", $headers));
?>
2番目のメールに対してヘッダー配列を再度指定する必要はありません。ヘッダーの文字列連結も '$ headerers = 'MIME-Version:1.0'のようにすることができます。 $ headers。= 'コンテンツタイプ:text/html; charset = iso-8859-1 ';' –
ここで複数の重複ヘッダが問題になりますか?私は複数の 'from'ヘッダを禁止するサーバからのエラーメッセージを読みましたが、RFCの中には何の参照も見つけられません。 – Progrock