JUnit

Mule SMTP testing with MUnit MailServer Mock

Very often we use Mule SMTP connector in flows. How to ensure it is sending emails as expected? Let's write a test case for it.

Manik Magar

4 minute read

Testing Mule SMTP using MUnit MailServer Mock We often use Mule SMTP connector in flows. But how to make sure that emails gets sent as expected? MUnit provides MailServer that we can use to mock real SMTP server and verify the mails sent by SMTP connector. Lets see how we can write munit test case for below subflow: <context:property-placeholder location="munit-mailserver-demo.properties" /> <sub-flow name="subflow-mail-sender"> <set-variable variableName="emailSubject" value="#[‘Welcome to UT’]" doc:name="Set Subject"/> <smtp:outbound-endpoint host="${email.