我可以在不发送电子邮件的情况下使用SwiftMailer验证SMTP
作者:互联网
我正在尝试使用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 thestart()
method on the
created Transport.
标签:laravel,php,swiftmailer 来源: https://codeday.me/bug/20191027/1948420.html