2
votes

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: [email protected] - 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
You should accept that guy's answer, as he is totally correct.rm-vanda

1 Answers

6
votes

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.