雅虎smtp不发送邮件,但相同的代码适用于gmail.Need help.working在本地服务器上

时间:2013-12-30 11:31:33

标签: php smtp phpmailer

yahoo SMTP邮件程序的示例代码

此代码适用于Gmail,但适用于雅虎显示

SMTP -> ERROR: Failed           to connect to server: (0) 
SMTP Error: Could not connect to SMTP host. Message has been sent.......

with port no 465
SMTP -> ERROR: MAIL not accepted from server: 501 Syntax error in arguments 

The following From address failed: root@localhost Message has been sent.......


<?php
include('class.phpmailer.php');
include('class.smtp.php');
try {
$mail = new PHPMailer();  
$mail->IsHTML(true);
$mail->SMTPDebug  = 1;
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.mail.yahoo.com"; //smtp host
$mail->Port = 25; //port no.
$mail->Username = "eg@yahoo.com"; //account 
$mail->Password = "pass"; //password
$fromname = "name";
$email="someone@gmail.com";
$abcd="-------------";
$To = trim($email,"\r\n");
  $tContent   = '';

  $tContent .="<table width='550px' colspan='2' cellpadding='4'>
        <tr><td align='center'><img src='imgpath' width='100' height='100'></td></tr>
        <tr><td height='20'>&nbsp;</td></tr>
        <tr>
          <td>
            <table cellspacing='1' cellpadding='1' width='100%' height='100%'>
            <tr><td align='center'><h2>YOUR TEXT<h2></td></tr/>
            <tr><td>&nbsp;</td></tr>
            <tr><td align='center'>Name: ".trim($abcd,"\r\n")."</td></tr>
            <tr><td align='center'>ABCD TEXT: ".$abcd."</td></tr>
            <tr><td>&nbsp;</td></tr>                
            </table>
          </td>
        </tr>
        </table>";

  $mail->FromName = $fromname;        
  $mail->Subject = "Your Details."; 
  $mail->Body = $tContent;
  $mail->AddAddress($To); 
  //$mail->set('X-Priority', '1'); //Priority 1 = High, 3 = Normal, 5 = low
  $mail->Send();
    echo 'Message has been sent.......';
} catch (phpmailerException $e) {
echo $e->errorMessage();
}
?>

1 个答案:

答案 0 :(得分:0)

对于雅虎,您可能需要雅虎加帐户。请参阅以下yahoo smtp:

的要求
Yahoo! Mail Outgoing Mail (SMTP) Server: smtp.mail.yahoo.com
Use Authentication: Yes
Port: 25 or 587    
Yahoo! Mail Incoming Mail (POP3) Server: Only available in Yahoo! Mail Plus
Account Name: Your full email address or your Yahoo! ID
Email Address: Your email address
Password: Your Yahoo! ID password

注意1:如果您的Internet服务提供商(ISP)阻止端口25,则必须使用备用SMTP端口号,例如587。

注2:AT&amp; T客户使用smtp.att.yahoo.com和端口465使用SSL

注3:如果您使用的是Yahoo!小型企业电子邮件,更多详情请见Here

其他提供商可以使用Outlook / Hotmail,AOL外发邮件