我遇到了phpMailer的问题,我无法发送任何电子邮件,它给了我这个错误:
2016-03-03 21:32:09 SERVER -> CLIENT: 2016-03-03 21:32:09 SMTP NOTICE: EOF caught while checking if connected 2016-03-03 21:32:09 SMTP Error: Could not authenticate. 2016-03-03 21:32:09 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Erreur : SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
这是我的代码:
<?php require('phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'ssl://smtp.gmail.com';
$mail->SMTPAuth= true;
$mail->Username='myadress@gmail.com';
$mail->Password='passwordgmail';
$mail->Port = 587;
$mail->SMTPDebug = 2;
$mail->SMTPSecure = 'ssl';
$mail->SetFrom('myadress@gmail.com', 'Name');
$mail->AddAddress('someone@gmail.com', 'HisName');
$mail->Subject = 'Subject';
$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 'Error : ' . $mail->ErrorInfo;
} else {
echo 'Ok!!';
}
?>
我尝试了所有找到的答案,但到目前为止都没有。我也试过其他端口,25和465不起作用,并给我其他错误。如果有人可以帮助我,那将是非常好的=)。谢谢
答案 0 :(得分:21)
您正在In [2]: for row in response.xpath('(//table[@class="standard_tabelle"])[1]/tr[not(th)]'):
...: print row.xpath(".//a[contains(@href, 'report')]/@href").extract_first()
...:
/report/premier-league-2015-2016-manchester-united-tottenham-hotspur/
/report/premier-league-2015-2016-afc-bournemouth-aston-villa/
/report/premier-league-2015-2016-everton-fc-watford-fc/
/report/premier-league-2015-2016-leicester-city-sunderland-afc/
/report/premier-league-2015-2016-norwich-city-crystal-palace/
使用SMTPSecure = 'ssl'
。那不行。使用Port = 587
/ 465或ssl
/ 587;不要混淆它们。错误消息链接到的故障排除指南中介绍了此(以及许多其他问题)。
另请注意,tls
值中的ssl:
前缀会覆盖Host
中的值,因此我建议您将其从中删除。
答案 1 :(得分:1)
require('phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->IsSMTP(true);
$mail->Host = 'smtp.gmail.com'; // not ssl://smtp.gmail.com
$mail->SMTPAuth= true;
$mail->Username='myadress@gmail.com';
$mail->Password='passwordgmail';
$mail->Port = 465; // not 587 for ssl
$mail->SMTPDebug = 2;
$mail->SMTPSecure = 'ssl';
$mail->SetFrom('myadress@gmail.com', 'Name');
$mail->AddAddress('someone@gmail.com', 'HisName');
$mail->Subject = 'Subject';
$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 'Error : ' . $mail->ErrorInfo;
} else {
echo 'Ok!!';
}
https://www.google.com/settings/u/0/security/lesssecureapps启用此功能