我在帐户中启用了安全性较低的应用,但仍然是相同的error
。
邮件无法发送.Mailer错误:SMTP连接()失败
我试过免费主机000webhost。这是我的代码
require 'PHPMailerAutoload.php'; $mail = new PHPMailer; //$mail->SMTPDebug = 3; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'leets@gmail.com'; // SMTP username $mail->Password = 'private'; // SMTP password $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 465; // TCP port to connect to $mail->setFrom('leets@gmail.com', 'tEst'); $mail->addAddress('leets@gmail.com'); // Add a recipient $mail->addAddress('ellen@example.com'); // Name is optional $mail->addReplyTo('info@example.com', 'Information'); $mail->addCC('cc@example.com'); $mail->addBCC('bcc@example.com'); $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'Here is the subject'; $mail->Body = 'Hello ,Click On the link to reset password'; $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; } else { echo 'Message has been sent'; } ?>
请帮助。
答案 0 :(得分:0)
是否更改为端口587帮助?
smtp.Host =" smtp.gmail.com&#34 ;; smtp.Port = 587;
答案 1 :(得分:0)
->我尝试在 000WebHost 中使用相同的方法,但是经过一些研究,我发现000WebHost免费版不支持 SMTP
->您尝试 Infinity Free 托管此托管支持 SMTP