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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3547388/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 10:10:45  来源:igfitidea点击:

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

phpauthenticationsmtpswiftmailer

提问by VDVLeon

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 "[email protected]" using 2 possible authenticators

无法使用 2 个可能的身份验证器使用用户名“[email protected]”在 SMTP 服务器上进行身份验证

I know for sure that the login-info is correct.

我确信登录信息是正确的。

采纳答案by VDVLeon

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

回答by roneo

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.

这可能是旧的,但有人可能会通过这个获得帮助。我也遇到了同样的问题,并在我的 gmail 帐户上收到一封邮件,指出有人试图通过电子邮件客户端或其他站点入侵您的帐户。然后我搜索并发现下面的操作可以解决这个问题。

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#connectedappsAt the bottom, towards right there is an option "Allow less secure apps". If it is "OFF", turn it on by sliding the button.

此外,您可以尝试此操作,转到https://myaccount.google.com/security#connectedapps在底部,向右有一个选项“允许安全性较低的应用程序”。如果它是“OFF”,请通过滑动按钮将其打开。

回答by Mint

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 和 mailman(FKA SMTP 调整)[?]

回答by user777161

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.

它可能不是 Swift Mail 的问题。这是 Yaml 解析器的问题。如果您的密码只有数字,那么发送到 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”

回答by Sydwell

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.

我很困惑,因为邮件服务器肯定需要这些凭据。

回答by VolkerK

The server might require some kind of encryption and secure authentication.
see http://swiftmailer.org/docs/sending.html#encrypted-smtp

服务器可能需要某种加密和安全身份验证。
http://swiftmailer.org/docs/sending.html#encrypted-smtp

回答by user3857499

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 !

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

回答by Ardian C.

try putting username in double quote "username", somehow that fixed for me.

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

回答by Jesus Rodriguez

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.

此外,来自谷歌的两步身份验证可能是问题所在。

回答by Marek D.

You perhaps use the wrong username.

您可能使用了错误的用户名。

I had a similar error. Ensure you're not using uppercase while logging into server.

我有一个类似的错误。确保您在登录服务器时没有使用大写字母。

Example: [email protected]

示例:[email protected]

If you use ->setUsername('JacekPL'), this can cause an error. Use ->setUsername('jacekpl')instead. This solved my problem.

如果使用->setUsername('JacekPL'),这可能会导致错误。使用->setUsername('jacekpl')来代替。这解决了我的问题。

回答by Suraj

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.

我使用 gmail 帐户和 Google 的 SMTP 服务器发送电子邮件。问题是由于 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 的流程将我的网络主机识别为通过我的帐户发送电子邮件的有效实体,问题解决了。