Skip to content
KaarrotGet notified
← Blog

Catch outgoing email when developing PHP locally on Windows

By ·

A password reset or a test newsletter sent by mistake from your local machine can reach real customers. A mail catcher prevents that: it accepts every message your app sends and keeps it on your computer.

How a mail catcher works

A mail catcher is a small SMTP server that listens on a local port. Your app sends mail to it as if it were a normal mail server. Instead of delivering anything, the catcher stores each message and shows it in an inbox where you can check the subject, HTML, plain text and headers.

Laravel

Laravel reads its mail settings from .env. Point it at a local SMTP server:

MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=1025
MAIL_ENCRYPTION=null

Clear the config cache if you have cached it:

php artisan config:clear

WordPress

WordPress sends email through PHP’s mail() function by default, and on Windows that usually goes nowhere. Install an SMTP plugin and use these settings:

  • Host: 127.0.0.1
  • Port: 1025
  • Encryption: none
  • Authentication: off

Then send a test email from the plugin’s settings page.

Plain PHP

If you use a library such as PHPMailer or Symfony Mailer, set the SMTP host to 127.0.0.1 and the port to 1025, with no TLS and no authentication.

With Kaarrot

Kaarrot runs a mail catcher on port 1025 by default, and messages show up in its Mail screen. See the mail catcher docs.

Kaarrot is a free, open-source PHP environment for Windows.

PHP versions, Nginx, databases, mail and HTTPS .test domains in one install.

Get notified at launch