Skip to main content

Testing Emails with Mailtrap

Mailtrap.io provides a simple way to test outbound emails from your self-hosted SMTP server without sending them to real recipients. Instead, Mailtrap captures emails in a test inbox where you can review them.

Testing emails in a local development environment typically requires complex email authentication setup (SPF, DKIM, DMARC). Mailtrap eliminates this complexity by providing a sandboxed environment to verify email content and functionality.

Prerequisites

  1. Create a Mailtrap account
  2. In the Mailtrap dashboard, select "Email Testing" from the left navigation
  3. Click "Inboxes" and then select your inbox
  4. In the Integration tab, find your SMTP credentials which include:
    • Host (sandbox.smtp.mailtrap.io)
    • Port (choose from available options: 25, 465, 587, or 2525)
    • Username
    • Password

Configure Medplum Server

  1. Open your Medplum server configuration file (default location for local development: packages/server/medplum.config.json)

  2. Set your sender email address:

"supportEmail": "support@example.com"
  1. Add Mailtrap SMTP settings:
"smtp": {
"host": "sandbox.smtp.mailtrap.io",
"port": 587,
"username": "username",
"password": "password"
}

Testing

After saving the configuration, restart the Medplum server. All emails will now be sent to your Mailtrap inbox. You can test this by:

The emails will appear in your Mailtrap inbox instead of being delivered to actual recipients.