简体   繁体   English

尝试在php中使用Yahoo SMTP发送邮件

[英]Trying to send mail using yahoo smtp in php

Please can some one suggest me codes to send mails using yahoo smatp, and php.. 请有人给我建议代码,以便使用yahoo smatp和php发送邮件。

require("class.phpmailer.php"); // be sure to change this to your location!

$mail = new PHPMailer();    
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier    

$mail->Host = "smtp.mail.yahoo.com"; // sets yahoo as the SMTP server    
$mail->Port = 25; // set the SMTP port    
$mail->Username = "sumthing@yahoo.com"; // yahoo username    
$mail->Password = "password"; // yahoo password

$mail->From = "sumthing@yahoo.com";
$mail->FromName = "myname";    
$mail->AddAddress("you@example.com");    
$mail->Subject = "Test PHPMailer Message";    
$mail->Body = "Hi! \n\n This was sent with phpMailer_example3.php.";

if(!$mail->Send()) {

    echo 'Message was not sent.';    
    echo 'Mailer error: ' . $mail->ErrorInfo;

} else {

    echo 'Message has been sent.';

}

This code is giving me errrors 'Could not connect to SMTP host". 此代码使我犯了“无法连接到SMTP主机”的错误。

Many of the sites providing SMTP do not support SSL (SMTP-S). 提供SMTP的许多站点不支持SSL(SMTP-S)。 If supported is usually in different port, such as 465. Connecting to 465 often fails. 如果支持,通常是在其他端口(例如465)中。连接到465通常会失败。 Try commenting out 尝试注释掉

$mail->SMTPSecure = "ssl"

Try also first without authentication to make sure the connection works. 也请先尝试不通过身份验证,以确保连接正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM