SMTP Gmail服务器SSL错误

时间:2011-12-29 13:57:47

标签: php ssl smtp

我使用此编码使用gmail发送邮件,但是我收到了以下错误,这里当我删除了ssl部分,它的工作,但我dint接收任何电子邮件(也在垃圾邮件内部检查)。还有其他问题吗?

$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";
}

1 个答案:

答案 0 :(得分:2)

启用Apache中的mod_ssl(搜索配置文件)和openssl PHP扩展(检查php.ini)