我写了一些代码使用PHPMailer从我的PHP脚本发送电子邮件。出于某种原因,脚本不发送消息。发送电子邮件从PHP脚本
这里是我的代码:
<?php
require_once("PHPMailer/class.phpmailer.php");
$mail=new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "[email protected]";
$mail->Password = "PASSHERE";
$mail->SetFrom = "[email protected]";
$mail->AddAddress("[email protected]");
$mail->Subject = "Confirm Web Lock Registration!";
$mail->Body = "Please confirm your Web Lock Registration by clicking here!";
$mail->WordWrap = 50;
if(!$mail->Send())
{
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo "Message Sent!";
}
?>
此相呼应的错误:
SMTP Error: Could not connect to SMTP host. Message was not sent.Mailer error: SMTP Error: Could not connect to SMTP host.
你是否得到了你的错误消息,如果有的话,它是什么? – 2010-10-21 17:19:43
你能提供更多关于这个问题的信息吗?它打印出错误信息,还是说“发送消息!”但你仍然没有收到它? – erjiang 2010-10-21 17:20:14
@Zachary Brown:绝不会像这样公开分享您的用户名和密码:) – Sarfraz 2010-10-21 17:21:23