我正在尝试使用PHPMailer发送邮件,它可以在我的本地主机上工作但是当我在免费托管网站byethost.com上使用它时,它说“PHPMailer错误:以下发件人地址失败:vinceagno@gmail.com :调用Mail()而不连接“
我已尝试更改FROM地址,但结果仍然相同。
这是我的代码。
<?php
require 'class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = 'smtp';
$mail->SMTPAuth = true;
$mail->Host = 'ssl://smtp.gmail.com'; // "ssl://smtp.gmail.com" didn't worked
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
// or try these settings (worked on XAMPP and WAMP):
// $mail->Port = 587;
// $mail->SMTPSecure = 'tls';
$mail->Username = "XXXXXXXX@gmail.com";
$mail->Password = "XXXXXXXX";
$mail->IsHTML(true); // if you are going to send HTML formatted emails
$mail->SingleTo = true; // if you want to send a same email to multiple users. multiple emails will be sent one-by-one.
$mail->From = "vinceagno@gmail.com";
$mail->FromName = "Hotdog";
$mail->addAddress("vince_agno@live.com","User 1");
$mail->Subject = "Testing PHPMailer with localhost";
$mail->Body = "Hi,<br /><br />This system is working perfectly.";
if(!$mail->Send())
echo "Message was not sent <br />PHPMailer Error: " . $mail->ErrorInfo;
else
echo "Message has been sent";
?>
提前谢谢。