Hi all,

Background: I have a script that sends an email using PHPMailer. The recipient is not receiving them because the spam filter on the receiving end is blocking them.
According to thier IT department the headers are not sending the "senders" email address.

The code below is simple but can anyone see why the email would be picked up by the spam filter.

$to = $_SESSION['imaintemail'];
$subject = $_SESSION['companyname']. " Room Audit" ;

$headers = "From: Support NaveX" . "<support@domainname.com.\r\n";
$headers .= "X-Sender: <support@domainname.com>\r\n";
$headers .= "X-Mailer: PHP\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "Return-Path: " . "<support@domainname.com>\r\n";
$headers .= 'Cc: support@domainname.com' . "\r\n";




$out =  "Room ID: " . $_POST['HotelID']. "\n";
$out .= "\n";
$out .=  "Audited by : " . $_SESSION['name_f'] . " " . $_SESSION['name_l']. "\n";
$out .= "\n";
$out .=  "Audit Date : " . $inspectiondate. "\n";
$out .= "\n";
$out .=  "Room Audit - Room No: " . $_POST['Room']. "\n";
$out .= "\n";
$out .= . $_POST['Seq06']. "\n";
$out .= "\n";
$out .=  . $_POST['Seq07']. "\n";
$out .= "\n";

mail( $to, $subject, $out, $headers );	


Many thanks for any help or advice you can provide.

Cheers,

Blackbox

    First problem I notice is your 'From' header isn't quite correct:

    From: Support NaveX<support@domainname.com.

    As far as the 'Sender' header, it is assumed to be the same as the 'From' address if it isn't explicitly present. Is the SMTP server you're using to send the messages permitted to send e-mails on behalf of the domain you have in the From address? Does that domain have an SPF record?

      You appear to be missing the ">" at the end of the from header.

        sneakyimp;11035009 wrote:

        Some big no-nos are having your SENDER and FROM be different email addresses.

        Er... what? The whole point the Sender header exists is so that you are able to specify a different address from the 'From' header.

          bradgrafelman;11035011 wrote:

          Er... what? The whole point the Sender header exists is so that you are able to specify a different address from the 'From' header.

          It's been awhile since I was wrangling with the mail() function and having mail delivery trouble but, as I recall, having these two values be different resulted in a higher spam score which would result in the email going into the junk. I could be remembering incorrectly and I know that the point of Sender is so that you can specify that the email was actually sent by someone other than the person it is from. At the same time, exploiting this is an obvious way to try and conceal spam. Also, I seem to recall that the Sender header might be set by the server itself so manually specifying one could lead to trouble? Sadly, I cannot recall the particulars. Perhaps we could arrange a test...

          My primary point was that using PHPMailer or PEAR::Mail sort of eliminates the need to create any mail headers yourself and that your script can send email just like you would yourself -- by logging into a mail server, authenticating, and submitting the message.

          It's also helpful set up an SPF record.

            sneakyimp;11035033 wrote:

            It's also helpful set up an SPF record.

            And have a DNS PTR record that matches the forward DNS. GMail bit us with this one recently....

              Write a Reply...