Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List-Unsubscribe in header prevents email from being delivered to gmail

I am using phpmailer to send email.

When I add the list-unsubscribe the email gets delivered to all accounts, except gmail. It just gets dropped, it doesn't go into spam, it just never arrives at the gmail account. When I remove the list-unsubscribe, it successfully gets sent to the gmail account.

This is the list-unsubscribe that I am using:

List-Unsubscribe:<http://keepity.com>,<mailto:[email protected]>

This is how its called in phpmailer:

$mail->AddCustomHeader("List-Unsubscribe:<http://keepity.com>,<mailto:[email protected]>");

This is the full function that calls phpmailer. If I comment out the list-unsubscribe then the mail gets delivered to gmail account, otherwise it never arrives. Does anyone know why it would not be delivered?

static function phpmailer_sendmail($mail,$from,$fromAlias,$to,$replyTo,$replyToAlias,$subject,$html,$text) {

    require_once (JPATH_COMPONENT.DS.'PHPMailer-master/class.phpmailer.php');

    $mail = new PHPMailer(true); // by setting TRUE you enable exceptions
    $mail->IsSMTP(true); // SMTP

    $mail->SMTPAuth   = true;  // SMTP authentication
    $mail->Mailer = "smtp";

    $mail->Host= "xyz"; // Amazon SES
    $mail->Port = 465;  // SMTP Port
    $mail->Username = "xyz";  // SMTP  Username
    $mail->Password = "xyz";  // SMTP Password

    $mail->ClearAllRecipients(); 
    $mail->ClearAddresses();
    $mail->ClearCCs();
    $mail->ClearBCCs();
    $mail->ClearReplyTos();
    $mail->ClearAttachments();
    $mail->ClearCustomHeaders();
    $mail->SetFrom($from, $fromAlias);
    $mail->AddReplyTo($replyTo,$replyToAlias);
    $mail->Subject = $subject;
    $mail->IsHTML(true);  
    $mail->Body    = $html;
    $mail->AltBody = $text;
    $address = $to;
    $addressAlias = $to;
    $mail->AddAddress($address, $addressAlias);
    $mail->AddCustomHeader("List-Unsubscribe:<http://keepity.com>,<mailto:[email protected]>"); 
    $mail->Send();



}
like image 253
user2776791 Avatar asked Sep 13 '13 15:09

user2776791


1 Answers

the function addCustomHeader gets 2 arguments and the unscribe value format should be

  <[email protected]>, <http://url_to_unscribe.com>

here is an example how it should be called :

  $mail->addCustomHeader("List-Unsubscribe",'<[email protected]>, <http://keepity.com/?email='.$address.'>');
like image 56
foxdanni Avatar answered Sep 29 '22 01:09

foxdanni