【发布时间】:2020-11-27 01:09:49
【问题描述】:
我知道有很多指南,但我尝试了很多都没有结果。 我还尝试重新调整参数,以便发件人在 replyTo 之前进行,反之亦然,等等,但仍然如此。
这个想法是让收件人看到它来自 something@gmail.com,但在回复时(人工或机器人作为退回电子邮件)始终回复 noreply@custom.com
无论我做什么,退回的电子邮件总是发送到 something@gmail.com 而不是 noreply@custom.com
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
require 'apps/PHPMailer/src/Exception.php';
require 'apps/PHPMailer/src/PHPMailer.php';
require 'apps/PHPMailer/src/SMTP.php';
try {
$mail = new PHPMailer(true);
$mail->CharSet = 'UTF-8'; // UTF8 Encoding
$mail->Encoding = 'base64'; // Needs to be set with UTF8
//$mail->SMTPDebug = SMTP::DEBUG_SERVER; // Enable verbose debug output
$mail->isSMTP(); // Send using SMTP
$mail->Host = "smtp.gmail.com"; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = "something@gmail.com"; // SMTP username
$mail->Password = "somePassword"; // SMTP password
$mail->SMTPSecure = "tls";
$mail->Port = 587; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
//Sender
$mail->setFrom('something@gmail.com');
$mail->addReplyTo('noreply@custom.com');
$mail->Sender = 'noreply@custom.com';
// Recipient
$mail->addAddress('fndsgfds@fsscd.com');
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = "test bouncing";
$mail->Body = "teting";
//$mail->AltBody = strip_tags($row_campaign['text']);
$mail->MessageID = $messageId; // removed from example here, but is stated above
$mail->addCustomHeader('In-Reply-To', $messageId);
$mail->send();
}
catch (Exception $e) {
echo "Error: {$mail->ErrorInfo}";
die();
}
unset($mail);
知道问题出在哪里吗? PHPMailer 6.1.6
【问题讨论】:
-
从地址试试这个:
<something> noreply@custom.com -
您好,请详细说明,因为我不明白您的意思
-
好吧,点击docs,我的观点变成了:
$From = 'noreplay@custom.com'; $FromName='something'; -
也不起作用...同样的问题
标签: php smtp phpmailer email-bounces