【发布时间】:2011-12-29 13:57:46
【问题描述】:
我使用此编码使用 gmail 发送邮件,但收到以下错误,当我删除 ssl 部分时,它可以正常工作,但我没有收到任何电子邮件(也在垃圾邮件中检查)。还有什么问题吗?
$mail = new phpmailer;
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug = 1;// enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "un"; // GMAIL username
$mail->Password = "pwd"; // GMAIL password
$mail->SetFrom('test@gmail.com', 'Bharanidharan');
$mail->AddReplyTo("test@gmail.com","Vishal Kumar");
$mail->AddAddress("test@gmail.com","Bharani");
$mail->Subject = "Hey, check out";
$body = "hey, check email";
$mail->MsgHTML($body);
$address = "test@gmail.com";
$mail->AddAddress($address, "test");
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
【问题讨论】:
-
实际的错误信息在哪里?
-
SMTP -> 错误:无法连接到服务器:无法找到套接字传输“ssl” - 您在配置 PHP 时是否忘记启用它? (72165504) SMTP 错误:无法连接到 SMTP 主机。邮件程序错误:SMTP 错误:无法连接到 SMTP 主机。