Setting SMTP locally for testing in Playwright or Cypress

| 1 min read

Nodemailer comes with a service https://ethereal.email/ that setup testing SMTP and catches all emails sent. In fact, email never reaches the destination inbox and you can test how it will be displayed. Very handy tool!

Click “Create Ethereal Account”

After creating an account you will get a page with your SMTP details

SMTP connection details

Now, you need to create a file in the repo .env or if you are using nextjs .env.local and fill in the SMTP connection with what you see on this page. None of the below should be left blank.

# .env / .env.local
EMAIL_SERVER_USER=
EMAIL_SERVER_HOST=
EMAIL_SERVER_PASSWORD=
EMAIL_SERVER_PORT=
EMAIL_FROM=

Next, you can go to https://ethereal.email/messages, and there you will see caught messages. The inbox should look like this:

https://ethereal.email/messages

💡 This setup is just for tests. If you have your own SMTP or are going into production you should change it.