Makerkit uses Ethereal for email testing, a neat service that catches all the email sent from the application.
Ethereal is an incredibly useful during development because it allows us to freely test the emails sent while testing, especially if we're designing pixel-perfect emails with MJML.
Another alternative is setting up a fully local SMTP server with SMTP4Dev and Docker. This can be preferable if you prefer not to send data to an external service or if you need to work offline.
Let's see how we can get it done!
Running the Docker Instance
To run the SMTP4Dev Docker image, ensure you're running Docker, and then run the following command:
docker run --rm -it -p 3300:80 -p 2525:25 rnwood/smtp4dev
We've initialized the HTTP server at localhost:3300, so go ahead and give it a try!
Configuring Makerkit
Now we have to add the correct configuration to and make a small adjustement to the codebase.
As we've said, Makerkit uses Ethereal by default: we need to remove that. Open the file at src/core/email/send-email.ts
and delete the lines 22-24:
if (configuration.emulator) { return getEtherealMailTransporter();}
Then, we update the configuration at src/configuration.ts
with the following email setup:
email: { host: '0.0.0.0', port: 2525, user: 'user', password: 'pass', senderAddress: 'test@makerkit.dev',},
And that's pretty much it! To test that everything works, send an email using the application by inviting a member from the Members page.
🎉 We now have a fully local email server to test our emails!