【发布时间】:2014-10-18 05:55:45
【问题描述】:
大家好,我收到了这个错误,
无法发送邮件。Mailer 错误:以下发件人地址失败:hehe.gmail.com:调用 Mail() 时未连接。
<?php
require '/PHPMailer_5.2.4/class.phpmailer.php';
$mail = new PHPMailer;
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'hehe@gmail.com'; // SMTP username
$mail->Password = 'xxx'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted
$mail->Port = 465;
$mail->From = 'hehe@gmail.com';
$mail->FromName = 'Mailer';
$mail->AddAddress('hehe@gmail.com'); // Add a recipient
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->IsHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
我该如何解决?谢谢!
【问题讨论】:
-
可以加
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only看看一些dbug语句吗? -
@Jens 你好,给你。 SMTP -> 错误:无法连接到服务器:无法找到套接字传输“ssl” - 您在配置 PHP 时是否忘记启用它? (1302733632)
-
@Jens 我也在使用 WAMP
-
看here也许这有帮助。
-
还是不行。我不知道为什么。