Configuring mail for sentry self-hosted

Configuring mail for sentry self-hosted

This blog is the fourth post in the Sentry self-hosted series. We will set up the mail configuration for your Sentry self-hosted instance in this post. This post will assume you already went over the previous posts in the series to set up the Sentry instance and configure the DNS AND NGINX configuration.

There are two ways to configure mail on Sentry:

  1. Built-in mail server
  2. Third-party mail server

Built-in mail server

Sentry ships with a built-in outgoing SMTP server set up out of the box.

Self-hosted Sentry ships with a built-in outgoing SMTP server powered by exim4. The default configuration is set to use this server. All you need to do is to set a valid address for mail.from setting in config.yml and the FQDN of your Sentry instance for SENTRY_MAIL_HOST in .env. Keep in mind that if you start sending too many emails to public addresses, your new server may get marked as a spammer and banned.

To enable the default mail server, you will need to update the config.yml file under path_to_installation/sentry/config.yml

Screen Shot 2022-03-15 at 3.28.49 PM.png

You will need to change the mail.from to the email from which you wish to receive emails. It could be something like sentry@yourdomain.com

After saving the changes to config.yaml, you must restart Sentry instance. You can do so with the following command in the root directory of your installation.

docker-compose restart

Third-party mail server

If you prefer to use a third-party service for sending emails, you can also do that. There are a lot of services that you can use; here are a few:

  1. MailChimp
  2. MailGun
  3. SendGrid

...

After signup up to an account, you would need the following information:

  1. SMTP host: this is a URL to the mail server host
  2. SMTP port: the port number
  3. SMTP username
  4. SMTP password

After retrieving the following information, you will need to update the config.yaml file with the above information.

Screen Shot 2022-03-15 at 3.50.43 PM.png

After saving the changes to config.yaml, you must restart Sentry instance. You can do so with the following command in the root directory of your installation.

docker-composer restart

Conclusion

After updating the config.yaml file and initiating a restart. You can go into the sentry instance and send a test email in the settings

Screen Shot 2022-03-15 at 3.53.04 PM.png

If you send a test mail and do not receive it, check your spam folder as it might have been marked as spam. If the email was not being sent for other reasons, like misconfiguration, Sentry would display a message with the error. If it fails with no message, you will need to put on your debugging hat and check the logs for more details.

If you have any questions or need any help, don't hesitate to DM me or ask your question in the comments.

Good luck!

Did you find this article valuable?

Support Malek Hijazi by becoming a sponsor. Any amount is appreciated!