我在本地网络服务器上设置phpmailer时遇到了困难,并希望得到任何帮助
我正在运行xamppp 1.7.4和php 5.3.5 - 我每次尝试发送邮件时都会收到以下错误消息
SMTP Error: Could not connect to SMTP host.
这是我现在正在使用的代码
require("resources/phpmailer/class.phpmailer.php");
//send the email with an email containing the activation link to the supplied email address
$mailer = new PHPMailer();
$mailer->IsSMTP(); // telling the class to use SMTP
$mailer->Mailer = "smtp";
$mailer->Host = "ssl://smtp.gmail.com";
$mailer->Port = 587;
$mailer->SMTPAuth = true; // turn on SMTP authentication
$mailer->Username = $email_kite;
$mailer->Password = $emailpass_kite;
$mailer->From = $email_kite;
$mailer->FromName = 'Kite';
$mailer->Body = 'Testing';
$mailer->Subject = 'Get started with Kite';
$mailer->AddAddress($email);
if(!$mailer->Send())
{
// message not sent
echo '<p class="c7">Unfortunately the <b>activation</b> email could not be sent and user registration has failed. Please go <a href="register.php">back</a> and try again.</p>';
echo '<br><img src="resources/img/spacer.gif" alt="" width="1" height="10">';
include_once ("resources/php/footer.php");
exit;
}
else
{
// message sent
"Email sent successfully!";
}
}
谢谢!
答案 0 :(得分:1)
尝试使用
$mailer->Port = 465;
端口587用于TLS,SSL端口为465。