gpt4 book ai didi

php - 我可以在不发送电子邮件的情况下使用 SwiftMailer 对 SMTP 进行身份验证吗

转载 作者:可可西里 更新时间:2023-11-01 00:59:08 25 4
gpt4 key购买 nike

我正在尝试使用 Laravel 中的 SwiftMailer 验证登录凭据。我需要在不实际发送电子邮件的情况下验证 SMTP 服务器的登录凭据。

我正在尝试做这样的事情:

$client = Swift_SmtpTransport::newInstance($smtpServer, $smtpPort, 'ssl');
$client->setUsername($this->smtpUser);
$client->setPassword($this->smtpPass);
$client->authenticate();

Swift_SmtpTransport 上没有authenticate() 方法,但如果有类似的东西我可以使用,那就太好了。

我在源代码中找不到合适的函数:https://github.com/swiftmailer/swiftmailer/blob/master/lib/classes/Swift/Transport/AbstractSmtpTransport.php

有没有一种方法可以使用 SwiftMailer 在 SMTP 服务器上尝试验证身份验证而无需发送电子邮件?

最佳答案

来自他们的 manual :

If you need to know early whether or not authentication has failed and an Exception is going to be thrown, call the start() method on the created Transport.

关于php - 我可以在不发送电子邮件的情况下使用 SwiftMailer 对 SMTP 进行身份验证吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32317350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com