Swift Mailer does not return smtp mail failure

心已入冬 提交于 2019-12-11 03:00:13

问题


I am using Swiftmailer to send emails with SMTP

I need to get response from SMTP, but what I am trying is not working. Is it even possible?

I tried an invalid email: dima44324d@vdaszdsd1dw.com - on the code below, which does not return errors

    if (!$mailer->send($message, $fails))
    {
          echo "Failures:";
          print_r($fails);
          return false;
    }

    return true;

P.S. I don't want to use PhpMailer because I have other issues with it.


回答1:


Remember that Swiftmailer simply hands the email over to an SMTP server. It does not actually deliver it. It's not Swiftmailer's job to determine if the email address you're telling it to send to is valid or not. As long as the address conforms to RFC822 standards, it'll be accepted by Swiftmailer, and be accepted by whatever SMTP server you're using.

It's only when that SMTP server attempts to actually DELIVER the email to the invalid hostname that you'll get a failure. By that point, Swiftmailer's already disconnected and reported success - it has accomplished its mission. The failure has occured farther down the line, outside of Swiftmailer's view.



来源:https://stackoverflow.com/questions/7272742/swift-mailer-does-not-return-smtp-mail-failure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!