How can I intercept local SMTP attempts?

Posted on


I’m doing some development work and need an app that will intercept any local SMTP attempts.

By intercept I mean that with zero configuration this application will receive mail on the local computer sent to any email address. So if I’m working on a PHP application and I use the mail() function I can send to any email address I want and this application will receive it like a typical mail client., would all be received as mail by this application.

I know I’ve seen one but for the life of me I cannot remember what it was called.


WireShark will allow you to monitor all of the network traffic, and you can filter it by the required port to see only the SMTP traffic (emails).

In order for your application (any application, for that matter) to send mail, the application will need access to a mail server. That mail server can either be running locally, or on a different system (such as your ISP’s mail server).

The PHP implementation, as far as I can tell, can either directly invoke a local mail transfer agent (MTA), such as sendmail, or contact a (local or remote) mail server via SMTP.

So the easiest option would probably be to install a local mail server (for how to do this, see e.g. Set up local SMTP and POP3 for testing mail send and receive loop ). Then configure the local mail server to never send out any mail, but just queue everything it gets. Finally, configure PHP to use this mail server.

The relevant PHP config settings for email sending are SMTP, sendmail_path etc..

Leave a Reply

Your email address will not be published. Required fields are marked *