PHP Swift 邮件程序:无法使用 2 个可能的身份验证器在 SMTP 上进行身份验证
当我使用 PHP Swift 邮件程序向此服务器发送电子邮件时: smtp.exchange.example.com 如下:
// Load transport
$this->transport =
Swift_SmtpTransport::newInstance(
self::$config->hostname,
self::$config->port
)
->setUsername(self::$config->username)
->setPassword(self::$config->password)
;
// Load mailer
$this->mailer = Swift_Mailer::newInstance($this->transport);
// Initialize message
$this->message = Swift_Message::newInstance();
// From
$this->message->setFrom(self::$config->from);
// Set message etc. ...
// Send
$this->mailer->send($this->message);
我收到一个奇怪的错误:
无法在 SMTP 服务器上使用用户名“[电子邮件受保护] 进行身份验证“使用 2 个可能的验证器
我确信登录信息是正确的。
When I send an email with the PHP Swift mailer to this server: smtp.exchange.example.com like this:
// Load transport
$this->transport =
Swift_SmtpTransport::newInstance(
self::$config->hostname,
self::$config->port
)
->setUsername(self::$config->username)
->setPassword(self::$config->password)
;
// Load mailer
$this->mailer = Swift_Mailer::newInstance($this->transport);
// Initialize message
$this->message = Swift_Message::newInstance();
// From
$this->message->setFrom(self::$config->from);
// Set message etc. ...
// Send
$this->mailer->send($this->message);
I get a strange error back:
Failed to authenticate on SMTP server with username "[email protected]" using 2 possible authenticators
I know for sure that the login-info is correct.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
这可能已经过时了,但有人可能会通过这个获得帮助。我也遇到了同样的问题,并在我的 Gmail 帐户上收到一封邮件,指出有人试图通过电子邮件客户端或其他网站入侵您的帐户。
然后我搜索并发现执行以下操作可以解决这个问题。
转到 https://accounts.google.com/UnlockCaptcha
并解锁您的帐户以通过其他媒体/网站进行访问。
更新:2015
另外,您可以尝试一下,转到 https://myaccount.google.com/security#连接的应用程序
在底部右侧有一个选项“允许安全性较低的应用程序”。如果它是“关闭”,请滑动按钮将其打开。
更新:2021 年
Google 网址现已更改为:https://myaccount.google.com/lesssecureapps 。系统会要求您重新登录
This might be old but somebody might get help through this. I too faced the same problem and received a mail on my gmail account stating that someone is trying to hack your account through an email client or a different site.
THen I searched and found that doing below would resolve this issue.
Go to https://accounts.google.com/UnlockCaptcha
and unlock your account for access through other media/sites.
UPDATE : 2015
Also, you can try this, Go to https://myaccount.google.com/security#connectedapps
At the bottom, towards right there is an option "Allow less secure apps". If it is "OFF", turn it on by sliding the button.
UPDATE : 2021
The google URL has now changed to : https://myaccount.google.com/lesssecureapps. You will be asked to relogin
我遇到了同样的问题,因此我禁用了 WHM root 登录的一项设置,如下所示:
I had the same issue, so I've disabled one setting on my WHM root login, which is as follows :
我真的有同样的问题,最后我解决了。
这很可能不是 Swift Mail 的问题。这是 Yaml 解析器的问题。
如果您的密码只有数字,则发送给 swift 的密码最终不会相同。
你需要用双引号修复它
密码:“61548921”
I really have the same problem, finally, i solved it.
its likey not the Swift Mail's problem. It's Yaml parser's problem.
if your password only the digits, the password senmd to swift finally not the same one.
you need fix it with double quotes
password: "61548921"
我刚刚收到同样的错误。
奇怪的是,评论了凭证行
,问题就消失了。
我很困惑,因为邮件服务器肯定需要这些凭据。
I just received the same error.
The strange thing is that commented the credential lines
And the problem disappeared.
I'm puzzled because the mail server definitely needs those credentials.
我尝试了这里提到的几乎所有可能的建议,但对我来说,在我的 Google 帐户安全设置选项卡中将“访问不太安全的应用程序”更改为“启用”后,问题得到了解决。希望这对其他人有用!
I tried almost all the possible suggestions mention here but for me problem got solved after changing "Access for less secure apps" to ENABLE in my Google account security settings tab. Hope this might useful for others !
服务器可能需要某种加密和安全身份验证。
请参阅http://swiftmailer.org/docs/sending.html#encrypted-smtp
The server might require some kind of encryption and secure authentication.
see http://swiftmailer.org/docs/sending.html#encrypted-smtp
尝试将用户名放在双引号“用户名”中,不知何故这对我来说是固定的。
try putting username in double quote "username", somehow that fixed for me.
我遇到了同样的问题并解决了。首先尝试手动登录您的 Gmail 帐户。
此问题是由于 Google 检测到您的 Gmail 帐户已被滥用。例如,在短时间内发送大量电子邮件。
I faced the same problem and solved it. Try to log in manually to your gmail account first.
This issue is due to google has detected your gmail account has been abusing. E.g send a lot of emails over a short period of time.
您可能使用了错误的用户名。
我有一个类似的错误。确保登录服务器时没有使用大写字母。
示例: [email protected]
如果您使用
->setUsername ('JacekPL')
,这可能会导致错误。请改用->setUsername('jacekpl')
。这解决了我的问题。You perhaps use the wrong username.
I had a similar error. Ensure you're not using uppercase while logging into server.
Example: [email protected]
If you use
->setUsername('JacekPL')
, this can cause an error. Use->setUsername('jacekpl')
instead. This solved my problem.首先检查是否存在任何连接问题并且您可以访问 SMTP 服务器:
在终端类型中:
如果收到 220 响应,您可以访问 SMTP 服务器并且不存在连接问题,但如果与服务器的连接失败,请查看出现了什么问题你的网络。
如果服务器需要身份验证,请尝试通过用户名和密码在服务器上进行身份验证,看看是否出现问题。
最后看看服务器是否需要加密,如果是,openssl 和其他东西是否配置正确。
First check if there is any connectivity problem and you can reach the SMTP server:
In terminal type:
If you receive the 220 response you can reach the SMTP server and there is no connectivity problem but if the connection to the server failed see what's wrong in your network.
If the server needs auth try to authenticate on the server by username and password and see if something goes wrong.
At last see if the server requires encryption and if yes openssl and other stuff are configured correctly.
我遇到了同样的错误。
我使用 gmail 帐户和 Google 的 SMTP 服务器发送电子邮件。该问题是由于 SMTP 服务器拒绝授权,因为它将我的网络主机(我通过其发送电子邮件)视为入侵者。
我按照 Google 的流程将我的网络主机识别为通过我的帐户发送电子邮件的有效实体,问题得到了解决。
I got the same same error.
I was using gmail account and Google's SMTP server to send emails. The problem was due to SMTP server refusing to authorize as it considered my web host (through whom I sent email) as an intruder.
I followed Google's process to identify my web host as an valid entity to send email through my account and problem was solved.
如果您尝试从本地环境发送邮件,例如。 XAMPP 或 WAMP,每次都会发生此错误,请继续在您的网络托管或您用于生产的任何内容上尝试相同的代码。
此外,谷歌的两步身份验证可能是问题所在。
If you are trying to send mail from your local enviroment eg. XAMPP or WAMP, this error will occur everytime, go ahead and try the same code on your web hosting or whatever you are using for production.
Also, 2 step authentication from google may be the issue.
奇怪的是,发送电子邮件又可以了。我们没有改变任何东西,主人说他们也没有改变。我们认为服务器会重新启动左右。很奇怪:S
Strange enough sending emails works again. We did not change anything and the host say they did not either. We think a server restarts or so. It is strange :S