Closed huyufan closed 5 days ago
Yes, you are implementing those headers correctly. Unfortunately gmail provides a sub-standard approach to this, and they require that you have fully authenticated messages as well, i.e. all of SPF, DKIM, and DMARC have to pass before they will handle this header properly. They also require that you have a perfect sending record, so if one person reports your message as spam, the unsubscribe button will not be shown to anyone else. No it's not very helpful, but this is gmail, so what do you expect?
To set up one-click unsubscribe for Gmail emails, add the following two headers to outgoing emails:
1.List-Unsubscribe-Post: List-Unsubscribe=One-Click 2.List-Unsubscribe: https://solarmora.com/unsubscribe/example
my code $mail = new PHPMailer(true); $mail->isSMTP(); $mail->setFrom($sender, $senderName); $mail->Username = $usernameSmtp; $mail->Password = $passwordSmtp; $mail->Host = $host; $mail->Port = $port; $mail->SMTPAuth = true; $mail->SMTPSecure = 'tls'; $mail->Charset = 'utf-8'; $mail->addAddress($recipient); $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = $bodyHtml; $mail->AltBody = $bodyText; $url ="https://www.github.com/unsubscribt"; $mail->addCustomHeader('List-Unsubscribe-Post', 'List-Unsubscribe=One-Click'); $mail->addCustomHeader('List-Unsubscribe', '<' . $url . '>'); $mail->Send();
Gmail receives the emails, but there is no unsubscribe button visible.How to resolve this issue?