Test emails on localhost

On February 28, 2015 Nette conference spoke Adam Štipák (alias @newPOPE) shortly to test e-mail messages on localhost. It surprised me how many programmers was unable to reply how they make tests e-mails on localhost, so here we bring to you a short tutorial.

There are several approaches to test emails. Either you can choose to display using any supplement in Nette, for example mail-panel or interception set up e-mail for your localhost.

Catching emails on localhost

Download one of these programs that will listen on port 25.

In php.ini uncomment these lines:

[mail function]
smtp_port = 25
  • restart apache
  • Windows: run Test mail server tool
  • MAC OS X: sudo java -jar fakeSMTP-1.4.jar, set smtp method, set host as localhost, port 25 and Start Server
  • at least just send e-mail and native email client will catch it