DEV Community

Cover image for #30DaysOfAppwrite : Getting Started with SMTP
Christy Jacob for Appwrite

Posted on • Updated on

#30DaysOfAppwrite : Getting Started with SMTP


#30DaysOfAppwrite is a month-long event focused at giving developers a walkthrough of all of Appwrite's features, starting from the basics to more advanced features like Cloud Functions! Alongside we will also be building a fully-featured Medium clone to demonstrate how these
concepts can be applied when building a real-world app. We also have some exciting prizes for developers who follow along with us!

Getting Started with SMTP

Welcome to Day 11 ๐Ÿ‘‹. SMTP stands for Simple Mail Transfer Protocol. As with any other protocol, it defines some steps and guidelines that need to be adhered to by all the computers on a network. SMTP is an application layer protocol in the TCP/IP stack and works closely with something called the Mail Transfer Agent (MTA) to send your communication to the right computer and email inbox.

In order to enable email functionality in Appwrite, you will need to set up a proper SMTP configuration. Because email deliverability can be both tricky and hard, it is often easier to delegate this responsibility to a 3rd-party SMTP provider like MailGun or SendGrid. These providers help you abstract the complexity of passing SPAM filters by doing a lot of the advanced configuration and validation for you.

Feel free to register with any provider of your choice and skip to the Configuration section. Otherwise, follow along to learn how to get the SMTP credentials from Sendgrid.

Setting up SendGrid

  1. Create a SendGrid account here.

  2. Verify ownership of a single email address to use as a sender. Instructions can be found here.

  3. Setup an SMTP Relay under Email API -> Integration Guide and create an API Key.

  4. Down below, you should see all the credentials you need to set up SendGrid with Appwrite in the next step.


Appwrite offers multiple environment variables to customize your server setup to your needs. In order to enable SMTP, you need to change the Appwrite container's environment variables. The following are important for us:

Name Description
_APP_SMTP_HOST SMTP server hostname address. Use an empty string to disable all mail sending from the server. The default value for this variable is an empty string
_APP_SMTP_PORT SMTP server TCP port. Empty by default.
_APP_SMTP_SECURE SMTP secure connection protocol. This environment variable is empty by default. Change this variable 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.

To change these variables according to your needs, navigate to the appwrite directory where Appwrite was installed and edit the hidden .env file.
Enter fullscreen mode Exit fullscreen mode

In addition to these variables, you will also need to update _APP_SYSTEM_EMAIL_ADDRESS environment variable to match the Sender Email configured in your SMTP service. This is the email address recipients will see when they receive emails from your Appwrite instance. You can also update _APP_SYSTEM_EMAIL_NAME, which will update the Sender Name found on sent emails.

After you have finished updating, you need to restart your Appwrite stack using the following command from your terminal:

docker-compose up -d --remove-orphans --build --force-recreate
Enter fullscreen mode Exit fullscreen mode

That's it!

Go to your Appwrite console, log out from your account and try to recover your password by navigating to Forgot password?. If you have followed along with setting up the SMTP Server using SendGrid - this should also verify your integration.

If everything goes well, you should receive an email with instructions to reset your password. Obviously, this is not necessary and is only a test to check if the SMTP server is working.

Tomorrow we will discuss how we can use our SMTP server to allow our users to verify their accounts with the associated email address.


We hope you liked this write-up. You can follow #30DaysOfAppwrite on Social Media to keep up with all of our posts. The complete event timeline can be found here

Feel free to reach out to us on Discord if you would like to learn more about Appwrite, Aliens or Unicorns ๐Ÿฆ„. Stay tuned for tomorrow's article! Until then ๐Ÿ‘‹

Top comments (5)

manoel_filho_5fd2cb93fcba profile image
Manoel Filho • Edited

Hello Christy! It's a perfect content. I dont know the reason of it, bu is it possible to see more detaisl about SMTP erros? I am not able to send messages with appwrite with Mailgun. Every moment I see "has failed Exception: Error sending mail: SMTP Error: data not accepted"

bonglv profile image
Ly Van Bong

no sp smtp outlook 365

smppatel99999 profile image
Sahil Patel

I am as well not able to send emails using Sendinblue. appwrite works fine but the emails are not send. Do not know why

bonglv profile image
Ly Van Bong

Please help, I have reconfigured mail config as on new outlook exchane 365. but it seems that the feature related to sending mail is still not working, I have checked but no error message.