PHP mail function and spam

Discussion in 'PHP' started by fatabbot, Jul 23, 2006.

  1. #1
    Hello,

    I'm sending mail to users after they register, so they need to confirm their registration, but alot of time, the mail ends up in the spam box of the user or gets completely blocked, so they cannot finish their registrations.
    I'm using this code for the header of the mail:

    
    <?
    ...
    $header = "From: noreply@mydomainname.com\n"; 
    $header .= "MIME-Version: 1.0\n"; 
    $header .= "Content-Type: text/html; charset=iso-8859-1\n"; 
    $header .= "X-Priority: 3\n"; 
    $header .= "X-MSMail-Priority: Normal\n"; 
    $header .= "X-Mailer: PHP / ".phpversion()."\n";
    ...
    ?>
    
    Code (markup):
    The $mailcontent and $subject is simply a string. For the actual send of the mail i use:

    mail($mailaddress, $subject, $mailcontent , $header)


    What can i do to prevent this from happening?
     
    fatabbot, Jul 23, 2006 IP
  2. coderlinks

    coderlinks Peon

    Messages:
    282
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try setting the X-Mailer to something used by real mail clients like Outlook, Thunderbird etc. I dont know the exact values to use, but I will check and tell. Also make sure that the From address is valid.

    You can also try using PHPMailer.
    http://phpmailer.sourceforge.net/

    Thomas
     
    coderlinks, Jul 23, 2006 IP
  3. Xig

    Xig Peon

    Messages:
    75
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If you are sending an HTML e-mail, it is wise to include a plain-text version also. I understand this will reduce the number of false-positives from spam checkers.
     
    Xig, Jul 24, 2006 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,824
    Likes Received:
    4,539
    Best Answers:
    123
    Trophy Points:
    665
    #4
    Another vote for phpMailer - it's used by phpList and it generally gets through spam filters if the content is good.

    Try putting a bit more in the email than just a welcome, put an intro note and a reminder of the url where the site is etc. May help it look more like a regular email.
     
    sarahk, Jul 24, 2006 IP
  5. Gordaen

    Gordaen Peon

    Messages:
    277
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Another thought is to install spam assassin and send a test message to yourself and see what flags it triggers. They also have a guide about some things to do to help limit the chance of it being discarded as spam (not privelaged enough to post links so try google: AvoidingFpsForSenders)

    Are the users all using a specific client or all different clients?
     
    Gordaen, Jul 24, 2006 IP
  6. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I would recommend that you drop all that junk in the header and only send a plain text message. There is no reason to include any graphics or advertising crappola or redirection URLs because those are among the things that attract the attention of spam filter rule-sets.

    Your message should be sweet and simple:

    "Thank you for registering at
    www.XXX.com
    Code (markup):
    To gain full access to our (website or website or whatever), please go to the following URL to complete the registration process:

    http://www.XXX.com/registrartion.php?code=thisUsersCode
    Code (markup):
    Thank you!
    "

    Unless your domain is blacklisted, that kind of email is probably going to get through.
     
    clancey, Jul 25, 2006 IP
  7. fatabbot

    fatabbot Well-Known Member

    Messages:
    559
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    138
    #7

    All different clients.
    Most problems occur with people using hotmail, gmail, yahoo mail, etc...
     
    fatabbot, Jul 26, 2006 IP
  8. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You can't always prevent it from happening, if you could then the spammers would use the same method.
     
    mad4, Jul 26, 2006 IP
  9. Xig

    Xig Peon

    Messages:
    75
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Just another thought - you may also want to check your server's IP address against Spam Black Lists (here's a few), in case a spammer has used your IP address in the past.
     
    Xig, Jul 27, 2006 IP