4

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: <kenny.XXX@hotmail.com>' . "\r\n";
$headers .= 'From: <XXX@srv30.000webhost.com>' . "\r\n";
$headers .= 'Cc: XXX@srv30.000webhost.com' . "\r\n";
$headers .= 'Bcc: XXX@srv30.000webhost.com' . "\r\n";
$text="hello";
$text = str_replace("\n.", "\n..", $text);
mail('Kenny Worden:<kenny.XXX@hotmail.com>','Leos Realm account verification!',$text,$headers);
?>

If this helps anyone:

SMTP : localhost(srv30.000webhost.com)

SMTP PORT: 25

  • 3
    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. – judda Apr 26 '11 at 23:30
  • nothing in the junk folder... why? –  Apr 26 '11 at 23:44
  • Have you tried running the very same script in another server (which uses another SMTP server for sending mail) – gd1 Apr 27 '11 at 00:11

3 Answers3

2

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.

Sabeen Malik
  • 10,816
  • 4
  • 33
  • 50
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.)

staticsan
  • 29,935
  • 4
  • 60
  • 73
0

code likes fine, anything you do that makes it look like spam will block it from hotmail try creating spf records for your domain, and even signatures

check your mail server is not blacklisted, this can cause problems http://www.mxtoolbox.com/

As @staticsan recommends php-mailer or also http://swiftmailer.org/ are other options you can use try that might help

bumperbox
  • 10,166
  • 6
  • 43
  • 66