Search code examples
phpsmtpphpmailer

How to validate SMTP credentials before sending email in PHP?


Since it's so hard to find an answer, I'm thinking this might be impossible. If so, I'd like confirmation that it's impossible.


Solution

  • It is not impossible.

    You can program the SMTP interaction yourself and check for confirmation in the SMTP protocol that the credentials were accepted. For that approach, you would have to do socket-level communication with the SMTP server (e.g. using the [PHP Sockets] service1).

    To learn how the SMTP protocol works, try doing that with Telnet once by hand.

    http://technet.microsoft.com/en-us/library/aa995718(v=exchg.65).aspx