我正在使用PHPmailer,并希望回复一封电子邮件。我使用phpimap获取电子邮件及其message_id
。我试图使用PHPmailer回复电子邮件。我已经在addCustomHeader
中使用了message_id
和In-Reply-To
。当我运行代码并检查电子邮件时,它显示为新消息而不是回复。我错在哪里了?
require 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.domain.co.uk'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'test@domain.co.uk'; // SMTP username
$mail->Password = 'testing'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->FromName = 'Mailer';
$mail->addAddress('test_2@domain.co.uk'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->addCustomHeader('In-Reply-To', $message_id);
$mail->Sender = 'test@domain.co.uk';
$mail->Subject = 'testing';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}