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

Can I authenticate SMTP using SwiftMailer without sending an email

我正尝试在 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.