Thread: PHP Mail

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    19
    Rep Power
    0

    PHP Mail


    I am trying to setup a MIME email system and I had it sending mail perfectly just with errors. I have made some switches and now it sends with no errors but is being caught by spam filters.

    -Outlook adds the HTML message as an attachment..
    -School account said it was not sent my the correct user (it was sending it as(www.data) but I add -f to fix it and now its being caught
    -Seems to go fine to gmail and yahoo...

    Here are the headers from outlook that got the message as plain text but added the HTML as an attachment;

    Microsoft Mail Internet Headers Version 2.0
    Received: from VA10PWPEXC004.us.ad.xxx ([30.128.193.xxx]) by VAPWVBE016.us.ad.xxx with Microsoft SMTPSVC(6.0.3790.4675);
    Thu, 5 Jan 2012 16:07:30 -0500
    Received: from vaplpmr007.xxx ([198.22.82.xxx]) by VA10PWPEXC004.us.ad.xxx with Microsoft SMTPSVC(6.0.3790.4675);
    Thu, 5 Jan 2012 16:07:30 -0500
    Received: from vaplpmr007.xxx (vaplpmr007 [127.0.0.1])
    by localhost (Postfix) with SMTP id C417B950039
    for <xxxxxx>; Thu, 5 Jan 2012 16:07:32 -0500 (EST)
    Received: from xxx (rrcs-24-172-204-102.central.biz.rr [24.172.204.xxx])
    by vaplpmr007.xxx (Postfix) with ESMTP id 5F03F95000E
    for <xxxxxx>; Thu, 5 Jan 2012 16:07:32 -0500 (EST)
    Received: from localhost (localhost.localdomain [127.0.0.1])
    by xxxxxx (Postfix) with ESMTP id 2EA211F20A8
    for <xxxxxx>; Thu, 5 Jan 2012 16:08:09 -0500 (EST)
    X-Virus-Scanned: amavisd-new at xxx
    Received: from xxx ([127.0.0.1])
    by localhost (xxx [127.0.0.1]) (amavisd-new, port 10024)
    with ESMTP id DBLGJ4qaQ2I7 for <xxxxxx>;
    Thu, 5 Jan 2012 16:08:08 -0500 (EST)
    Received: by xxx (Postfix, from userid 33)
    id 8E3FD1F20A9; Thu, 5 Jan 2012 16:08:08 -0500 (EST)
    ToXxx: See forum rules)
    Subject: xxx
    X-PHP-Originating-Script: 0:MarketEmail2xxx
    From:xxxxxx
    Reply-To:xxxxxx
    MIME-Version: 1.0
    Content-Type: multipart/mixed; boundary = xxxmarket4f0611387fca0
    Message-Id: <20120105210808.8E3FD1F20A9xxx>
    Date: Thu, 5 Jan 2012 16:08:08 -0500 (EST)
    X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.1.5.210028
    Return-PathXxx: See forum rules)
    X-OriginalArrivalTime: 05 Jan 2012 21:07:30.0453 (UTC) FILETIME=[093CB450:01CCCBEE]

    --xxxmarket4f0611387fca0
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: base64

    --xxxmarket4f0611387fca0
    Content-Type: text/html; charset=ISO-8859-1
    Content-Transfer-Encoding: base64


    --xxxmarket4f0611387fca0--


    Here is a look at my actual header setup;

    //add From: header
    $headers = 'From:' . $from . "\n";
    $headers .= 'Reply-To:' . $from . "\n";
    $headers .= 'Return-Path:' . $from . "\n";

    //specify MIME version 1.0
    $headers .= "MIME-Version: 1.0\n";

    //unique boundary
    $boundary = uniqid("xxxmarket");

    //tell e-mail client this e-mail contains//alternate versions
    $headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n";


    //plain text version of message
    $body = "--$boundary\r\n" .
    "Content-Type: text/plain; charset=ISO-8859-1\r\n" .
    "Content-Transfer-Encoding: base64\r\n\r\n";
    //adds the remove me displaying email address
    $urlplain = " http:/"."/xxx/x.php?i=" . $to1[$i];
    $plainremove = $urlplain;
    //Counts the length
    $plaindumplength = strlen($plainremove);
    //adds the remove to the string
    $plaintxt .= $plainremove;
    $body .= chunk_split(base64_encode($plaintxt));

    //HTML version of message
    $body .= "--$boundary\r\n" .
    "Content-Type: text/html; charset=ISO-8859-1\r\n" .
    "Content-Transfer-Encoding: base64\r\n\r\n";
    //adds on the remove me displaying email address and link to php p$
    $urltest = " http:/" . "/xxx/removeme?remove=" . $to1[$i];
    $emaildump = "<p> This email was sent to " . $to1[$i] . " if you would like to $
    //Counts the length
    $dumplength = strlen($emaildump);
    //adds the remove to the string
    $htmltxt .= $emaildump;
    $body .= chunk_split(base64_encode($htmltxt));
    $body .= "--$boundary--";


    Then the mail;
    mail($to1[$i], $subject, $message, $headers, "-f $from"

    );
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2010
    Posts
    9
    Rep Power
    0
    Did you try using smtp authentication? check the code in the link below:

    http://www.codewalkers.com/c/a/Email-Code/Smtp-Auth-Email-Script/

    good luck!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    19
    Rep Power
    0
    Thank you, I found first I had to switch from
    Content-Type: multipart/mixed
    to
    Content-Type: multipart/alternative

    This fixed adding the html as an attachment, then I actually switched to swiftmailer and ended up getting catch by spam filters but at least there was no attachment (which means my code was correct after all).

    I finally figured out all I needed to do was to read up on spammer filters..> As it turns out Plain text and Html in alternate mixed messages need to be the same.

    Everything is good to go now, thank you

IMN logo majestic logo threadwatch logo seochat tools logo