Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
870 views
in Technique[技术] by (71.8m points)

email - PHP mail() function cannot send to hotmail?

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>' . "
";
$headers .= 'From: <XXX@srv30.000webhost.com>' . "
";
$headers .= 'Cc: XXX@srv30.000webhost.com' . "
";
$headers .= 'Bcc: XXX@srv30.000webhost.com' . "
";
$text="hello";
$text = str_replace("
.", "
..", $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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...