Working with Email ¶
Catching emails in development ¶
In the studio, you can enable relaying email to a specified SMTP endpoint.
HELO and mailtrap are easy SMTP endpoints to set up for development that provide UIs for reviewing emails sent to all recipients. When emails are configured to be relayed to these services, they will be trapped for review and never actually delivered to anyone externally, no matter what recipients you use. As opposed to overriding recipient emails to test email features, this approach enables you to verify that personalized bulk emails send the right content to the right recipients.
Using HELO ¶
- Download and open the HELO app
- Launch studio, run
start-all
-
Install and activate postfix email backend:
enable-email
-
Configure postfix email backend to relay to HELO app on Docker host machine:
enable-email-relay host.docker.internal 2525 studio
Or, using mailtrap:
enable-email-relay smtp.mailtrap.io 2525 mailtrapusername mailtrappassword
Sending a test email ¶
From the studio:
-
Install netcat:
hab pkg install --binlink core/netcat
-
Open SMTP connection:
nc localhost 25
-
Start SMTP session:
EHLO localhost.localdomain
-
Set sender:
MAIL FROM: <sender@example.com>
-
Set recipient:
RCPT TO: <recipient@example.com>
-
Set message:
DATA Subject: Hello world! This is the body of my email. Have a good day. .
-
Close SMTP session:
QUIT
-
Review postfix backend log:
less -S /hab/cache/sys.log