Mailer

Stormkit Mailer is designed to provide a straightforward way to send transactional emails directly from your application. This feature is ideal for sending automated notifications, password resets, and other essential email communications.

With just a few configuration settings, you can connect Stormkit Mailer to your SMTP provider and start sending emails quickly and reliably.

Configuration

  • Navigate to the Environments tab and select the environment (e.g., production or staging) where you want to set up email functionality.
  • Go to Config > Mailer Configuration.
  • On self-hosted instances, choose Use the instance's default mailer or Use custom SMTP settings.

Instance default mailer (self-hosted)

On a self-hosted instance, the instance admin can set up one SMTP account for the whole instance under Admin > Mailer: SMTP host, port, username, password and a From address. Each environment then chooses whether to use it or its own settings, so the SMTP account is configured once instead of in every environment.

An environment that uses the default mailer:

  • Sends emails that don't set a sender from the instance's From address. Your SMTP provider must allow any sender address your apps use.
  • Gets the default mailer's connection string as MAILER_URL.
  • Records its emails without sending them if the admin removes the default mailer, until it is configured again or the environment switches to custom settings.

Switching an environment to the default mailer removes its own SMTP settings. Use Send test email on the admin page to check the settings; the SMTP server's error is shown if it refuses the email.

Custom SMTP settings

In the Mailer Configuration panel, you will find the following fields. Fill them out according to your SMTP provider’s details:

Setting Description
SMTP Host Enter the hostname of your SMTP server
SMTP Port Set the port for your SMTP server. Common ports are 587 (TLS), 465 (SSL)
Username Enter the username for SMTP authentication. Typically the email address associated with your account.
Password Enter the password for SMTP authentication. Ensure this is securely stored and not shared publicly.

Environment Variables

When a mailer is configured, Stormkit will inject the following environment variable at build time and make it available at runtime:

Variable Description
MAILER_URL The SMTP connection string (e.g., smtp://user:pass@host:port)

Note: If an environment already has a custom MAILER_URL configured, it won't be overwritten.

Testing the Configuration

After entering your SMTP credentials, click the Send test email button to verify the configuration.

You should receive a confirmation email if the SMTP settings are correct. If there’s an error, double-check your SMTP settings or contact your SMTP provider for assistance.

Once you’re satisfied with the settings, click Save to store the SMTP configuration for your environment.

Example (Gmail)

Setting Value
SMTP Host smtp.gmail.com
SMTP Port 587
Username your-email@example.com
Password Your Gmail app password (if using 2FA, generate an app-specific password)

Sending emails programmatically

  • Generate an API key for your environment: Environment > Config > API Keys
  • Refer to our API documentation

Additional Notes

  • SMTP Security: Ensure that your SMTP credentials are kept secure and only accessible by authorized personnel.
  • App Passwords for Gmail: If you’re using Gmail as your SMTP provider and have two-factor authentication (2FA) enabled, you’ll need to create an app-specific password in your Google account.

Troubleshooting:

If you encounter issues, confirm the following:

  • Your SMTP host and port are correct.
  • Your email provider supports the port and authentication type you’ve selected.
  • Any firewall or security settings on your network allow outbound SMTP traffic.

For further assistance, refer to your SMTP provider’s documentation or reach out to us.