I’ve recently been needing to test emails with Moqui, and I came across a good solution. Moqui has a 3rd cousin twice removed framework called JHipster. I found this post by them about setting up a local SMTP server.
I’ve always thought setting up a local SMTP server would be too much of a pain for testing, but this was incredibly easy, and I thought I would share it.
All you need to do is add this to a demo data file and load it:
<!-- To get this working run docker run -p 1080:1080 -p 1025:1025 soulteary/maildev and go to http://localhost:1080 -->
<moqui.basic.email.EmailServer emailServerId="SYSTEM" smtpHost="localhost" smtpPort="1025"/>
<!-- Create a fromAddress for any email that you want to test -->
<moqui.basic.email.EmailTemplate emailTemplateId="PASSWORD_RESET" fromAddress="test@localhost"/>
Then run this on your local machine
docker run -p 1080:1080 -p 1025:1025 maildev/maildev
Then go to http://localhost:1080. You should see something like this:
There’s no need for a password or username by default (because it’s only for local development).
You can test this by running Moqui and going to http://localhost:8080/qapps/system/Security/UserAccount/UserAccountDetail?userId=EX_JOHN_DOE and click and accept the
Reset Password button.
we have been using Maildev for some time now, and it has been really helpful. We use the docker image maildev/maildev, I suppose it is the same project as you mention (GitHub - maildev/maildev: 📫 SMTP Server + Web Interface for viewing and testing emails during development.) but these docker images have more recent updates.
Great! I’ll have to use the maildev/maildev docker image.
Another option is the embedded SMTP server: org.subethamail:subethasmtp is the maven ID.
It is enabled using a Moqui Conf XML file with a ToolFactory class, here is the OOTB setting in MoquiDefaultConf.xml, disabled by default:
<!-- SubEtha SMTP ToolFactory starts an SMTP server using the MOQUI_LOCAL EmailServer settings, emails received trigger EMECA rules -->
<tool-factory class="org.moqui.impl.tools.SubEthaSmtpToolFactory" init-priority="50" disabled="true"/>
This doesn’t do exactly what another SMTP server does, ie it won’t forward outgoing email, but it will receive email and trigger EMECA rules which can be used to process incoming email messages, or just log them for testing.
The eventual idea with this is to handle automation of incoming email, like adding comments to a WorkEffort or other CommunicationEvent sorts of things by replying to notification emails, or even managing incoming messages associated with transactional records like orders, invoices, etc along with a queue if needed for a human to look at it… or in general whatever you might imagine for handling incoming emails, and without having to poll a POP or IMAP account on another SMTP server.