0

PHP 関数で Request-Path ヘッダーを使用しようとしていますmail()が、機能しません。Return-Path は From ヘッダーに変更され続けます。

グーグルで役立つヒントを見つけましたが、多くのことを学びましたが、どれも役に立ちませんでした。

これが私が使用している非常に単純なコードです:

$headers ='From: "Marty"<from_param@gmail.com>'."\r\n";
//$headers .='Return-Path: return_path@gmail.com'."\r\n";
$headers .='Reply-To: reply_to@gmail.com'."\r\n";
$headers .='Content-Type: text/plain; charset="iso-8859-1"'."\r\n";
$headers .='Content-Transfer-Encoding: 8bit';

$returnPath = '-freturn_path@gmail.com';

if (mail('goldorak_loves_albator@gmail.com', 'My subject', 'My body', $headers, $returnPath)) {
    echo 'Message sent';
} else {
    echo 'Message not sent';
}

そして、これが私がこれまでに試したことです:

  • ヘッダーの改行あり\nおよび\r\n改行
  • $header文字列に Return-Path を使用
  • mail()関数の 5 番目のパラメーターとして Return-Path を使用
  • $headersinと inの両方で Return-Pathを使用$returnPath
  • $returnPath後の変数にスペースがある場合とない場合-f
  • 、スペースありとスペースなし-r$returnPathありとなし-f

私が読んだように、PHP ユーザーが Return-Path を置き換える exim 構成に問題がある可能性があります。Fromしかし、これはヘッダーに置き換えられているため、ここでは当てはまりません。

このコードは非常に単純なので、これは構成の問題であるとほぼ確信していますが、役立つものは何も見つかりません...

ご協力ありがとうございました !

編集:LinuxサーバーではEximを使用していないため、問題はそこから発生しません。SwiftMailer で同じ目標を達成しようとしましたが、役に立ちませんでした。Return-Path は引き続き無視されます....

require('swift/lib/swift_required.php');

$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
->setUsername('username@gmail.com')
->setPassword('myPassword');

$mailer = Swift_Mailer::newInstance($transport);

// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setTo(array('goldorak_loves_albator@gmail.com'))
->setFrom(array('from@gmail.com' => 'Myself'))
->setReturnPath('return_path@gmail.com')
->setBody('Here is the message itself')
;

// Send the message
$result = $mailer->send($message);

これは、SwiftMailer の例から直接取得したものです。

4

0 に答える 0