Appwrite default setup uses a default built-in SMTP server. The default SMTP server is a great way to get you started with using Appwrite quickly, but if you plan to move your setup to a production environment, you will have extra configuration work to do in order to make sure email providers respect your SMTP server.
Because email deliverability can be both tricky and hard, it is often easier to delegate this responsibility to a 3rd-party SMTP provider. This provider help you abstract the complexity of passing SPAM filters by doing a lot of the advanced configuration and validation for you.
In this document, you will learn how to connect your own SMTP server or a 3rd party SMTP provider like MailGun or SendGrid with Appwrite to help you get better email deliverability.
Update your docker-compose.yml File
Appwrite offers multiple environment variables to customize your server setup to your needs. To make Appwrite use your own SMTP server instead of the default build-in SMTP server, you need to change the Appwrite container environment variables.
_APP_SMTP_HOST - SMTP server host name address. Default value is: ‘smtp’
_APP_SMTP_PORT - SMTP server TCP port. Default value is: ‘25’
_APP_SMTP_SECURE - SMTP secure connection protocol. Empty by default, change to ‘tls’ if running on a secure connection.
_APP_SMTP_USERNAME - SMTP server user name. Empty by default.
_APP_SMTP_PASSWORD - SMTP server user password. Empty by default.
Remove the Default SMTP Container
As mentioned above, the Appwrite default setup includes the Appwrite default SMTP container. Now that you are using your own SMTP server setting, you don’t need it anymore. Just remove the SMTP container and relevant dependencies from your docker-compose.yml file:
Restart Your Appwrite Server
After you finished updating and saving your Appwrite docker-compose.yml server you need to restart your Appwrite stack using the following command from your terminal:
That’s it! Go to your Appwrite console again and try to create a new user. If everything went OK, you should get a welcome email in your new user email inbox. As of version 0.5, Appwrite uses its SMTP server to send welcome emails, password recoveries, and user invites. By using a well-configured SMTP server, you can make sure your users enjoy a maximum rate of email deliverability.