Function mail() in PHP versus Hotmail Junk Mail Box

Posted on 2007-07-30
Last Modified: 2013-11-19
I develop a function of sending of emails in PHP (on a dedibox, OS =  Fedora core5) by using the function mail($email_address, $subject, $message, $header).
PROBLEM: The mails sent arrive in the junk mail box of hotmail between-others.

How to make so that the messages fall into the "reception box" from my recipients?

I sailed through many forums and I am partly persuaded that all depends on the fourth parameter of mail().
If you know the good configuration of the $header, or of the server, I thank you in advance.
Question by:KCTeam
    LVL 2

    Expert Comment

    Does it even go to the junk folder? There are some specific headers you have to have to make it to hotmail.
    I could tell you about the headers but this sounds more complicated.

    Perhaps one good way is to test it against a server with spam assassin or something similar and see the reasons you get spam score. Then try to eliminate these reasons.

    Author Comment

    For the moment, i use only "simple email sending", with few text and an url link.
    The idea you gave is pretty good cpulse, but spamassassin doesn't work as the Hotmail server.

    What i need to know is "how configure my fourth parameter in the PHP function in the aim to send emails that won't be filter as spams by HOTMAIL ?" (it's a pretty difficult question)

    LVL 2

    Accepted Solution

    $mailHeaders = 'MIME-Version: 1.0' . "\r\n" .
    'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
    'From: Demo <>' . "\r\n" .

    mail($mailTo, $mailSubject, $mailMessage, $mailHeaders, '-f');

    Actually the fifth parameter that is important, it send email from the actual user and not from

    The above example is for HTML emails, if you dont use it then change the Content-type.

    Secondly, implement SenderID/SPF for your domain. All configurations are easily obtainable from
    a. Microsoft :
    b. SPF :

    Moreover, if your domain is new then it will stay in MSN spam filter unill it believes that you are not a spammer.

    Hope this helps.
    LVL 2

    Expert Comment

    Forgot to mention MSN Postmaster Guidelines at

    Author Comment

    With our team we solved the problem partly. Which poses problem it's that the mails we send to a member of aren't throwed in its reception mail box.

    I would like to know the criteria of concerning the undesirable mails...or a solution to permit us to finish our job.

    Thanks for help ;-)

    Author Closing Comment

    Thanks for your answer

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now