Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
865 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: <[email protected]>' . "
";
$headers .= 'From: <[email protected]>' . "
";
$headers .= 'Cc: [email protected]' . "
";
$headers .= 'Bcc: [email protected]' . "
";
$text="hello";
$text = str_replace("
.", "
..", $text);
mail('Kenny Worden:<[email protected]>','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 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...