简体   繁体   English

PHP Swift 邮件程序:无法使用 2 个可能的身份验证器在 SMTP 上进行身份验证

[英]PHP Swift mailer: Failed to authenticate on SMTP using 2 possible authenticators

When I send an email with the PHP Swift mailer to this server: smtp.exchange.example.com like this:当我将带有 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);

I get a strange error back:我收到一个奇怪的错误:

Failed to authenticate on SMTP server with username "user@example.com" using 2 possible authenticators无法使用 2 个可能的身份验证器使用用户名“user@example.com”在 SMTP 服务器上进行身份验证

I know for sure that the login-info is correct.我确信登录信息是正确的。

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.我也遇到了同样的问题,并在我的 gmail 帐户上收到一封邮件,指出有人试图通过电子邮件客户端或其他站点入侵您的帐户。 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.转到https://accounts.google.com/UnlockCaptcha和解锁您的帐户,通过其他媒体/站点的访问。

UPDATE : 2015更新: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".此外,您可以尝试此操作,转到https://myaccount.google.com/security#connectedapps在底部,向右有一个选项“允许安全性较低的应用程序”。 If it is "OFF", turn it on by sliding the button.如果它是“OFF”,请通过滑动按钮将其打开。

UPDATE : 2021更新:2021

The google URL has now changed to : https://myaccount.google.com/lesssecureapps .谷歌 URL 现在已更改为: https://myaccount.google.com/lesssecureapps You will be asked to relogin您将被要求重新登录

I had the same issue, so I've disabled one setting on my WHM root login, which is as follows :我遇到了同样的问题,所以我在 WHM 根登录时禁用了一项设置,如下所示:

WHM > Home > Server Configuration > Tweak Settings > Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak) [?] WHM > 主页 > 服务器配置 > 调整设置 > 将传出 SMTP 限制为 root、exim 和邮递员(FKA SMTP 调整)[?]

I really have the same problem, finally, i solved it.我真的有同样的问题,最后,我解决了它。

its likey not the Swift Mail's problem.它可能不是 Swift Mail 的问题。 It's Yaml parser's problem.这是 Yaml 解析器的问题。 if your password only the digits, the password senmd to swift finally not the same one.如果您的密码只有数字,那么发送到 swift 的密码最终不会相同。

swiftmailer:
    transport:  smtp
    encryption: ssl
    auth_mode:  login
    host:       smtp.gmail.com
    username:   your_username
    password:   61548921

you need fix it with double quotes password: "61548921"你需要用双引号密码修复它:“61548921”

I just received the same error.我刚刚收到同样的错误。

The strange thing is that commented the credential lines奇怪的是,评论了凭证行

// ->setUsername(self::$config->username)
// ->setPassword(self::$config->password)

And the problem disappeared.而问题就消失了。

I'm puzzled because the mail server definitely needs those credentials.我很困惑,因为邮件服务器肯定需要这些凭据。

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.我尝试了这里提到的几乎所有可能的建议,但对我来说,在我的 Google 帐户安全设置选项卡中将“访问不太安全的应用程序”更改为启用后,问题得到了解决。 Hope this might useful for others !希望这可能对其他人有用!

The server might require some kind of encryption and secure authentication.服务器可能需要某种加密和安全身份验证。
see http://swiftmailer.org/docs/sending.html#encrypted-smtphttp://swiftmailer.org/docs/sending.html#encrypted-smtp

尝试将用户名放在双引号“用户名”中,不知何故对我来说是固定的。

You perhaps use the wrong username.您可能使用了错误的用户名。

I had a similar error.我有一个类似的错误。 Ensure you're not using uppercase while logging into server.确保您在登录服务器时没有使用大写字母。

Example: JacekPL@lala.pl示例:JacekPL@lala.pl

If you use ->setUsername('JacekPL') , this can cause an error.如果您使用->setUsername('JacekPL') ,这可能会导致错误。 Use ->setUsername('jacekpl') instead.使用->setUsername('jacekpl')代替。 This solved my problem.这解决了我的问题。

I got the same same error.我得到了同样的错误。

I was using gmail account and Google's SMTP server to send emails.我使用 gmail 帐户和 Google 的 SMTP 服务器发送电子邮件。 The problem was due to SMTP server refusing to authorize as it considered my web host (through whom I sent email) as an intruder.问题是由于 SMTP 服务器拒绝授权,因为它认为我的网络主机(我通过它发送电子邮件)是入侵者。

I followed Google's process to identify my web host as an valid entity to send email through my account and problem was solved.我按照 Google 的流程将我的网络主机识别为通过我的帐户发送电子邮件的有效实体,问题解决了。

I faced the same problem and solved it.我遇到了同样的问题并解决了它。 Try to log in manually to your gmail account first.首先尝试手动登录您的 Gmail 帐户。 This issue is due to google has detected your gmail account has been abusing.这个问题是由于谷歌检测到您的 gmail 帐户被滥用。 Eg send a lot of emails over a short period of time.例如,在短时间内发送大量电子邮件。

First check if there is any connectivity problem and you can reach the SMTP server:首先检查是否有任何连接问题,您可以访问 SMTP 服务器:

In terminal type:在终端类型中:

telnet servername portnumber 

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.如果您收到 220 响应,您可以访问 SMTP 服务器并且没有连接问题,但如果与服务器的连接失败,请查看您的网络出了什么问题。

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.最后看看服务器是否需要加密,如果是,openssl 和其他东西配置正确。

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. XAMPP 或 WAMP,每次都会发生此错误,请继续尝试在您的网络托管或任何用于生产的代码上使用相同的代码。

Also, 2 step authentication from google may be the issue.此外,来自谷歌的两步身份验证可能是问题所在。

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很奇怪:S

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel,无法使用 3 个可能的身份验证器使用用户名“”在 SMTP 服务器上进行身份验证 - Laravel, Failed to authenticate on SMTP server with username "" using 3 possible authenticators 使用 2 个可能的身份验证器在用户名“***”的 SMTP 服务器上进行身份验证失败 - Failed to authenticate on SMTP server with username “***” using 2 possible authenticators 无法使用2个可能的身份验证器在SMTP服务器上使用用户名进行身份验证 - Failed to authenticate on SMTP server with username using 2 possible authenticators Laravel:无法使用 2 个可能的身份验证器在 SMTP 服务器上使用用户名进行身份验证 - Laravel :Failed to authenticate on SMTP server with username using 2 possible authenticators Swift_TransportException无法使用共享主机上的2个可能的身份验证器使用用户名email@domain.com在SMTP服务器上进行身份验证 - Swift_TransportException Failed to authenticate on SMTP server with username email@domain.com using 2 possible authenticators on shared host SMTP connect()失败的PHP邮件程序 - SMTP connect() failed PHP mailer 在PHP邮件中,SMTP连接失败 - in php mailer the smtp connection is failed 尝试使用 swift mailer、gmail smtp、php 发送邮件 - trying to send mail using swift mailer, gmail smtp, php 验证密码失败 smtp PHP - Failed to authenticate password smtp PHP PHP Mailer SMTP ERROR命令失败 - PHP Mailer SMTP ERROR Command Failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM