Send SMTP Emails with SendGrid
This page describes how to use SendGrid as an SMTP Relay to send emails from Medplum.
SMTP email is only available when self-hosting Medplum.
Medplum's hosted environment uses Amazon Simple Email Service (SES). Amazon SES is the default Medplum email provider.
Prerequisites
Be sure to perform the following prerequisites to complete this tutorial.
- Sign up for a SendGrid account
- Create and store a SendGrid API key with full access "Mail Send" permissions.
- Verify your SendGrid Sender Identity
See the SendGrid How to Send an SMTP Email guide for step by step instructions.
Configuring Medplum Server for SMTP
Open your Medplum server config file. When developing on localhost, the default config file location is packages/server/medplum.config.json
.
Change the supportEmail
to your Sender Identity email address:
"supportEmail": "support@example.com",
Add a new smtp
section for the SendGrid SMTP settings. Use your API key as the SMTP password:
"smtp": {
"host": "smtp.sendgrid.net",
"port": 587,
"username": "apikey",
"password": "YOUR_API_KEY"
}
Testing
Once your configuration settings are saved, restart the Medplum server. All subsequent emails will be sent via SendGrid SMTP Relay. For example, you can invite a new user or reset your password to send a new email.
If your SendGrid account is new, email delivery may be slow for the first 24 hours.