php mail()vs Yahoo:有人可以简单解释一下YAHOO从PHP邮件功能接收邮件的步骤吗? [英] Php mail() vs Yahoo: Can someone Simply Explain Steps required for YAHOO to receive mail from php mail function?

查看:142
本文介绍了php mail()vs Yahoo:有人可以简单解释一下YAHOO从PHP邮件功能接收邮件的步骤吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到数千个关于此主题的类似问题。并且肯定我了解SO中的标记为重复的问题

I have seen thousands of similar questions asked on this topic. And for sure am aware of the "MARKED AS DUPLICATE QUESTION" thing in SO.

但是,仍然不清楚该如何或做什么简单来说就是从PHP mail()函数获得yahoo收件箱电子邮件。

However, it is still not Clear how or what one has to do in simple terms to have yahoo Inbox emails from a PHP mail() function.

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

In the Yahoo site, they give a sample script to send mails like

链接 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

使用Yahoo的基本方法自己的合法网站失败。

Using this basic approach found in the Yahoo's own legitimate website fails.

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

The second suggestion would be (for PERL) but can be converted to PHP with some editing:

#!/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后看起来像这样:

After few edits to make it PHPish it looks like:

<?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 却无处可去。

The user_name2@gmail.com for GMAIL sends the Email as required but user_name@yahoo.com somehow does not go anywhere.

那么,我们应该做什么? ...如果YAHOO自己的示例不起作用,则:

So, what should we do?... If YAHOO's own samples are not working, then:

a)是否不赞成使用PHP mail()函数?...如果可以,那还有什么选择?

a) Is PHP mail() function getting deprecated?... If so, what is the alternative?

b)该功能是否仍然有效,我们如何提出 YAHOO收件箱友好 PHP代码?

b) Should the function still be valid, how do we come up with YAHOO Inbox friendly PHP Codes?

c)什么?

EDIT:

其他测试。

仅以这种格式进行了测试,由 PHP邮件建议()不发送电子邮件的功能

Just tested it in this format Suggest by 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";

Still Yahoo不收件箱。

EDIT2

我转到此链接: http://www.forensicswiki.org/wiki/Evolution_Header_Format

YAHOO表示标头应如下所示:

YAHOO said the header should be like this:

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

PHP mail()函数为主题。 ... GMail 再次收到 YAHOO 被拒绝...在日志

Thested with PHP mail() func. ... GMail received, again, YAHOO Rejected... I Get NO Error in the Logs

推荐答案

我终于在脸上露出了笑容。
他与@DaveRandom一起工作,帮助我提出了以下代码:

I Finally got a laaaaarge smile on my face. Working together with @DaveRandom, He helped me come up with these codes:


注意:波纹管使用的代码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 **

And this WORKED like VOODOO!... It sent mails to any provider. Including **YAHOO**

希望它可以帮助某人!

这篇关于php mail()vs Yahoo:有人可以简单解释一下YAHOO从PHP邮件功能接收邮件的步骤吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆