emailphpmaileremail-headersmailing-list

Mail list address visible in receivers To: field


I'm trying to set up a custom mailing list for my site.

When a user(user@bar.com) sends a mails to list@foo.com. The mail should automatically be sent to the subscribers.

Making the actual sending isn't that hard. But when the emails get delivered I get the "This message may not have been sent by..." warning.

This doesn't look to Cool.

First:

  1. How do I prevent this message from showing (Most important)
  2. How can I make the receiver see the list@foo.com address instead of their own. (Like google's mailing lists)

Note: The receiver should still be able to see the actual sender in the from field.

I've read some other posts on the topic, mentioning all kinds off different headers. But I Can't seem to get it to work.

I'm using PHPmailer and heres a part of my code:

<?php
    include(class.phpmailer.php);
    $real_to = "user@bar.com";
    $mail = new PHPMailer();
    $mail->IsMail();
    $mail->AddReplyTo($_POST['from_mail'], $_POST['from_name']);
    $mail->Host = "mail.foo.com";
    $mail->From = $_POST['from_mail'];
    $mail->Sender = "list@foo.com";
    $mail->MessageID = $_POST['msgID'];
    $mail->FromName = $_POST['from_name'];
    $mail->AddAddress($listmail);
    $mail->Subject  = $_POST['subject'];
    $mail->ContentType  = $_POST['content_type'];

    $mail->addCustomHeader("X-BeenThere: " . $listmail);
    $mail->addCustomHeader("Precedence: list");
    $mail->addCustomHeader("Precedence: list");
    $mail->addCustomHeader("Envelope-To: " . "list@foo.com");
    //$mail->addCustomHeader("Received: " . $_POST['received']);
    $mail->Body = $_POST['body'];
    $mail->Send();
?>

Solution

  • I ended up making a cronjob that updated the mail list adding all recipients as aliases instead. This solved all wierd message about the massage not originating from the sender. I dont know if this is a good method. But it works.

    I also added a PTR reccord. Installed DKIM suport and set up a SPF reccord. This solved all spam marking.

    Now the problem is solved.