gpt4 book ai didi

Php mail() 与雅虎 : Can someone Simply Explain Steps required for YAHOO to receive mail from php mail function?

转载 作者:搜寻专家 更新时间:2023-10-31 21:10:56 29 4
gpt4 key购买 nike

我已经看到关于此主题的数千个类似问题。可以肯定的是,我知道 SO 中的“标记为重复问题”

但是,从 PHP mail() 函数获取雅虎收件箱电子邮件,简单来说,如何或必须做什么仍然不清楚。

在 Yahoo 站点中,他们提供了一个示例脚本来发送邮件,例如

链接 http://help.yahoo.com/l/us/yahoo/smallbusiness/webhosting/php/php-03.html

    $email = "EMAIL TO";
$subject = "Test Message";
$msg = "This is a test message";

//$eLog="/tmp/mailError.log";

//Get the size of the error log
//ensure it exists, create it if it doesn't
//$fh= fopen($eLog, "a+");
//fclose($fh);
//$originalsize = filesize($eLog);

mail($email,$subject,$msg);

//NOTE: I commented out unneeded lines

使用在雅虎自己的合法网站上找到的这种基本方法失败了。

第二个建议是(对于 PERL)但可以通过一些编辑转换为 PHP:

#!/usr/bin/perl
print "Content-type: text/html\n\n";

$title='mail test';
$to='MAIL ADDRESS TO SEND TO';
$from= 'EMAIL@YOURDOMAIN.COM';
$subject='Using Sendmail';

open(MAIL, "|/usr/sbin/sendmail -t");

## Mail Header
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
## Mail Body
print MAIL "This is a test message from Yahoo \n";

close(MAIL);

print "<html><head><title>$title<
/title></head>\n<body>\n\n";

## START HTML content
print "<h1>$title</h1>\n";
print "<p>A message has been sent from $from to $to";
## END HTML CONTENT
print "\n\n</body></html>";

链接:http://help.yahoo.com/l/us/yahoo/smallbusiness/webhosting/php/php-17.html

经过几次编辑使其看起来像 PHPish:

<?php

///#!/usr/bin/perl

$title='_01_mail test';
$to='user_name@yahoo.com, user_name2@gmail.com';
$from= 'info@companyname.com';
$subject='_01_Using Sendmail';


## Mail Header
$headers = "To: $to\n";
$headers .= "From: $from\n";
$headers .= "Subject: $subject\n\n";
## Mail Body
$message = "<html><head><title>$title<
/title></head><body>
<h1>$title</h1>
<p>A message has been sent from $from to $to\n\n
</p></body></html>";

if ( mail($to,$subject,$message,$headers) ) {
echo "The email has been sent!";
} else {
echo "The email has failed!";
}

?>

GMAIL 的 user_name2@gmail.com 按要求发送电子邮件,但 user_name@yahoo.com 不知何故没有去任何地方。

那么,我们该怎么办?...如果雅虎自己的样本不工作,那么:

a) PHP mail() 函数是否已弃用?...如果是,替代方案是什么?

b) 如果该功能仍然有效,我们如何提出 YAHOO Inbox 友好 PHP 代码?

c) PHP mail() 函数的最佳实践是什么?

编辑:

额外的测试。

刚刚以这种格式测试过 PHP mail() function not sending email 建议:

$subject = "subject";
$message = "message";
$to = "USER_NAME_HERE@yahoo.com";
$type = "plain"; // or HTML
$charset = "utf-8";

$mail = "no-reply@".str_replace("www.", "", $_SERVER["SERVER_NAME"]);
$uniqid = md5(uniqid(time()));
$headers = "From: ".$mail."\n";
$headers .= "Reply-to: ".$mail."\n";
$headers .= "Return-Path: ".$mail."\n";
$headers .= "Message-ID: <".$uniqid."@".$_SERVER["SERVER_NAME"].">\n";
$headers .= "MIME-Version: 1.0"."\n";
$headers .= "Date: ".gmdate("D, d M Y H:i:s", time())."\n";
$headers .= "X-Priority: 3"."\n";
$headers .= "X-MSMail-Priority: Normal"."\n";
$headers .= "Content-Type: multipart/mixed;boundary=\"----------".$uniqid."\""."\n\n";
$headers .= "------------".$uniqid."\n";
$headers .= "Content-type: text/".$type.";charset=".$charset.""."\n";
$headers .= "Content-transfer-encoding: 7bit";

YAHOO 仍然没有收件箱。

EDIT2

我去了这个链接:http://www.forensicswiki.org/wiki/Evolution_Header_Format

YAHOO说header应该是这样的:

Subject: header test
From: Username <username@sendinghost.com>
To: Username <username@receivinghost.com>
Content-Type: text/plain
Date: Sat, 28 Jul 2007 11:52:35 +0200
Message-Id: <1185616355.19231.0.camel@localhost>
Mime-Version: 1.0
X-Mailer: Evolution 2.10.1
Content-Transfer-Encoding: 7bit

Thested with PHP mail() func. ... GMail 再次收到 YAHOO 拒绝...我没有错误日志

最佳答案

我终于在脸上露出了 laaaaarge 的笑容。与@DaveRandom 一起工作,他帮助我想出了这些代码:

NOTE: The code bellow uses PHPMailer

    <?php

$senderName = 'Erick Best'; //Enter the sender name
$username = 'erickbestism@yahoo.com'; //Enter your Email
$password = 'passwordHere';// Enter the Password


$recipients = array(
'erickbestism@gmail.com' => 'Erick Best',
'erickbestism@yahoo.com' => 'Yahoo User',
);
///That's all you need to do

//No need to edit bellow
require '../PHPMailerAutoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer();

// Set up SMTP
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.mail.yahoo.com";
$mail->Port = 587; // we changed this from 486
$mail->Username = $username;
$mail->Password = $password;

// Build the message
$mail->Subject = 'PHPMailer mail() test';
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
$mail->AltBody = 'This is a plain-text message body';
$mail->addAttachment('images/phpmailer_mini.gif');

// Set the from/to
$mail->setFrom($username, $senderName);
foreach ($recipients as $address => $name) {
$mail->addAddress($address, $name);
}

//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}

?>

这就像 VOODOO 一样工作!...它向任何提供者发送邮件。包括**YAHOO**

希望对大家有帮助!

关于Php mail() 与雅虎 : Can someone Simply Explain Steps required for YAHOO to receive mail from php mail function?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19555650/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com