PHP mail() function cannot send to hotmail?

11,178

Solution 1

Your code seems to be good. My guess is that there is something wrong at your servers end, check mail delivery logs or have your server admin look at them for you. Could be a routing/dns issue.

edit: i just tried that script on my server and it works well. immediately got email on my hotmail address.

Solution 2

You're missing the string "-f <from address>" as the fifth parameter.

The PHP Manual points out that you need to supply this so that the MTA will send the correct "From" address on the envelope. Setting it in the headers isn't enough. This sort of inanity is why I dis-recommend mail() and point people towards php-mailer or similar.

(The "envelope" refers to the conversation an MTA has with another MTA in order to deliver email.)

Share:
11,178

Related videos on Youtube

Admin
Author by

Admin

Updated on May 30, 2022

Comments

  • Admin
    Admin about 2 years

    Okay, I have searched on the internet for answers- sadly to no avail. I'm trying to send mail using the PHP mail() function so members can follow the link to register. It works for Gmail, Yahoo!, but not for Hotmail. Please help meh!!!

       <?php
    $headers .= 'To: <[email protected]>' . "\r\n";
    $headers .= 'From: <[email protected]>' . "\r\n";
    $headers .= 'Cc: [email protected]' . "\r\n";
    $headers .= 'Bcc: [email protected]' . "\r\n";
    $text="hello";
    $text = str_replace("\n.", "\n..", $text);
    mail('Kenny Worden:<[email protected]>','Leos Realm account verification!',$text,$headers);
    ?>
    

    If this helps anyone:

    SMTP : localhost(srv30.000webhost.com)

    SMTP PORT: 25

    • judda
      judda about 13 years
      Have you looked in the junk email folder, because there is nothing that would stop it from working for one mail server and not another.