无法使用PHPMailer通过Google SMTP发送邮件 [英] Unable to send mail through Google SMTP with PHPMailer

查看:417
本文介绍了无法使用PHPMailer通过Google SMTP发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google的SMTP与PHPMailer结合发送邮件,但无法正常工作.这是我的代码:

I'm trying to send out mail using Google's SMTP in combination with PHPMailer, but I can't get it to work. This is my code:

$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Username = "myemail@gmail.com";
$mail->Password = "**********";
$mail->Port = "465";

首先,我不完全了解应填写为"SMTPSecure"的内容,有人说"ssl",而有人说"tls".接下来是端口",我可以输入"465"或"587".但是,所有组合都不起作用...请注意,我使用的是常规的Gmail帐户,而不是Google Apps.在我的Gmail帐户中,我启用了"POP访问".

First I do not fully understand what should be filled in as 'SMTPSecure', some say 'ssl', other say 'tls'. Next for 'Port' I could enter '465' or '587'. But none of the combinations work... Note that I'm using a regular Gmail account and not Google Apps. In my Gmail account I've enabled 'POP access'.

我得到的错误是:"Must issue a STARTTLS command first".这意味着SSL失败了,但不知道为什么...

The error I get is: "Must issue a STARTTLS command first". Which means SSL failed, but don't know why...

推荐答案

好的,问题出在PHPMailer的版本上. 我更新到PHPMailer版本5,并且一切正常. 我使用的是phpMailer 1.02版.

Ok, the problem was the version of PHPMailer. I updated to PHPMailer version 5 and everything worked great. I was using phpMailer version 1.02.

这篇关于无法使用PHPMailer通过Google SMTP发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆