【问题标题】:Authentication with SMTP transport using Swiftmailer使用 Swiftmailer 通过 SMTP 传输进行身份验证
【发布时间】:2013-02-12 20:06:28
【问题描述】:

我正在使用 Swiftmailer 在基于 Yii 的应用程序中发送电子邮件,它运行良好,因此 Swiftmailer 扩展包装器没有问题。但是现在我想使用 SMPT 传输来针对邮件服务器对我的应用程序中的用户进行身份验证。我正在使用的代码:

$SM = Yii::app()->swiftMailer;

$mailHost = 'XXX'; 
$mailPort = XXX;

// New transport
$transport = $SM->smtpTransport($mailHost, $mailPort);

$transport->setUsername($username);
$transport->setPassword($password);
$transport->start();

if($transport->isStarted()){
    // authenticated;    
}else{
    // error;
}

$transport->stop();

这不起作用。当我设置真实的登录凭据时立即登录。但是当我输入错误的凭据时,它会花费一些时间,但最后它也登录了。我不知道为什么会发生这种情况,因为只有在使用真实凭据时 Swiftmailer 才能发送电子邮件。 我使用了正确的 API 函数?我做错了什么?

【问题讨论】:

    标签: authentication yii smtp swiftmailer


    【解决方案1】:

    查看the source,当您调用start() 时,started 始终设置为 True。

    我对 switfmailer 不熟悉,但您似乎需要检查 authenticate() 的结果

    【讨论】:

    • 是的! authenticate() 是类传输中的一种方法吗?我没见过。让我检查一下。
    猜你喜欢
    • 2013-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-10
    • 1970-01-01
    相关资源
    最近更新 更多