使用phpmailer在电子邮件上添加取消订阅链接?

时间:2017-05-17 14:23:21

标签: php email gmail phpmailer

我正在尝试在电子邮件之上添加取消订阅链接,例如: enter image description here这个。

这是我写的代码,

$mail = new PHPMailer;
$mail->MessageID = $message_send_id;
// Set PHPMailer to use the sendmail transport
$mail->isSendmail();
$mail->isHTML(true);  // Set email format to HTML
$mail->AddReplyTo(trim($_GET["in_rep_to"]));
$mail->addCustomHeader("List-Unsubscribe: <mailto:unsubscribe@lovenlove.info?subject=delete>,<http://lovenlove.info/nishat/unsubscribe.php?email=".$value[0]["address"].">");
//Set who the message is to be sent from
$mail->setFrom(trim($email_address), trim($value[0]["own_name"]));
//Set the hostname of the mail server
$mail->Hostname = trim($host_name);
$mail->addCustomHeader('In-Reply-To', $message_id);
$mail->addCustomHeader('References', $ref_id);

//mail addresscontains <*> this line to be edited
$mail->addAddress(trim($value[0]["address"]));
//Set the subject line
//code for subject here
$subject = $value[0]["message_to_send"]["subject"];
//code for body
$body = $value[0]["message_to_send"]["body"];

$mail->Subject = trim($subject);
$mail->Body    = trim($body);
//send the message, check for errors

if (!$mail->send()) echo "Mailer Error: " . $mail->ErrorInfo;

这会使用电子邮件发送标头List-Unsubscribe,但链接未显示在那里。我不知道这是不是这个过程。

我有DKIM: PASSSPF: NEUTRAL记录。

在邮件标题中显示List-Unsubscribe: <mailto:unsubscribe@lovenlove.info?subject=delete>,<http://lovenlove.info/nishat/unsubscribe.php?email=heatherb6353@gmail.com>。我找不到问题。

Here is a working message header

Here is my message header

0 个答案:

没有答案