-1
我已被搜查了很多小时来解决我的问题,我失败了。错误与邮件错误:SMTP连接()失败
这是我简单的代码使用PHPMailer的与Gmail
在XAMPP发送电子邮件,每次得到这个错误:
Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
,这是我PHP代码:
<?php
require_once('PHPMailer/PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->HOST = 'smtp.gmail.com';
$mail->PORT = '465';
$mail->isHTML();
$mail->Username = '##myemail##@gmail.com';
$mail->Password = '##mypass##';
$mail->SetFrom('[email protected]');
$mail->Subject = 'Hello World';
$mail->Body = 'A test email!';
$mail->AddAddress('[email protected]');
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
请帮帮我。
你检查了维基? https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#smtp-error-could-not-connect-to-smtp-host – modsfabio
你很可能有认证错误,但你应该设置'$ mail-> SMTPDebug = 2 '让我们知道错误是什么。 – Linek
[PHPMailer,SMTP connect()失败,可能出现与Gmail错误](http://stackoverflow.com/questions/25924651/phpmailer-smtp-connect-failed-error-with-gmail) – Synchro