我在标题中的@ yahoo.com电子邮件地址有问题,'来自:'。当我使用@ yahoo.com时它无法发送。但对于其他电子邮件地址,如@ gmail.com或@ ymail.com,它工作正常。我不知道怎么写才能让它与@ yahoo.com一起使用
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'To: Seller Name<vuthy32@gmail.com>' . "\r\n";
$headers .= 'From: Buyer Name <vuthy32@yahoo.com>' . "\r\n";
$headers .= "X-Mailer: PHP/".phpversion();
if(!mail($this->to, $this->subject, $email_body, $headers))
{
return false;
} else
{
return true;
}
答案 0 :(得分:1)
<?php
// Pear Mail Library
require_once "Mail.php";
$from = '<from.yahoo.com>';
$to = '<to.any.com>';
$subject = 'Hi!';
$body = "Hi,\n\nHow are you?";
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject
);
$smtp = Mail::factory('smtp', array(
'host' => 'ssl://plus.smtp.mail.yahoo.com',
'port' => '465',
'auth' => true,
'username' => 'johndoe@yahoo.com',
'password' => 'passwordxxx'
));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo('<p>' . $mail->getMessage() . '</p>');
} else {
echo('<p>Message successfully sent!</p>');
}
?>