localhost中的PHPMailer显示错误调用Mail()而未连接。我该怎么解决?

时间:2015-07-18 18:52:12

标签: php phpmailer

<?php
require("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();

// ---------- adjust these lines ---------------------------------------
$mail->Username = "mymail@gmail.com"; // your GMail user name
$mail->Password = "xxxxxxxxxx"; 
$mail->AddAddress("yourmail@yahoo.com"); // recipients email
$mail->FromName = "abc"; // readable name

$mail->Subject = "Sample Email";
$mail->Body    = "Here is the message you want to send to your friend."; 
//-----------------------------------------------------------------------

$mail->Host = "ssl://smtp.gmail.com"; // GMail
$mail->Port = 25;
$mail->IsSMTP(); // use SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->From = $mail->Username;
if(!$mail->Send())
    echo "Mailer Error: " . $mail->ErrorInfo;
else
    echo "Message has been sent";
?>
  

邮件程序错误:以下发件人地址失败:mymail@gmail.com:调用Mail()而未连接。

我该如何解决?

0 个答案:

没有答案