【发布时间】:2015-01-05 19:01:36
【问题描述】:
我从https://github.com/PHPMailer/PHPMailer 下载了一个邮件文件,并尝试在我的程序中使用它来发送电子邮件,但它导致我出现了一些错误。首先让我们看一下代码
include 'PHPMailer-master/class.phpmailer.php';
include 'PHPMailer-master/class.smtp.php';
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'ssl://smtp.gmail.com';
$mail->Port = 587; // or 587
$mail->IsHTML(true);
$mail->Username = "........@gmail.com";
$mail->Password = "*****";
$mail->SetFrom('.....@gmail.com');
$mail->Subject = "Test";
$mail->Body = "this the mail for subscription";
$mail->AddAddress('......@gmail.com');
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
运行此代码后,我收到错误消息:
SMTP -> ERROR: Failed to connect to server: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (1546610735)SMTP Connect() failed. Mailer Error: SMTP Connect() failed.
请让我知道问题所在,因为我已经看到其他帖子...但我没有得到任何提示
【问题讨论】:
-
你为什么要asked this question again...编辑上一个问题...