The Simple Mail Transfer Protocol (SMTP) is the standard protocol for sending email between servers. Almost every email service accepts mail over SMTP, from transactional email providers to workplace email, and you can also run your own mail server.
How does the integration work?
You can use the SMTP provider in Appwrite Messaging to send customized emails to your users through an email service that Appwrite doesn't have a dedicated provider for, or through a mail server you host yourself. Emails can be sent immediately or scheduled, to topics, users, or individual targets.
Appwrite connects to the host and port you set, signs in with your username and password, and encrypts the connection with SSL or TLS.
A Messaging provider sends the messages you create in Appwrite Messaging. To send authentication emails, such as email verification and password recovery, through your own server instead, set up a custom SMTP server for your project.
How to implement
To implement the SMTP provider in Appwrite Messaging, there are several steps you must complete:
Step 1: Get your SMTP settings
First, collect the SMTP settings from your email service or mail server: the host, the port, a username and password, and the encryption the server expects. Most services use port 587 with TLS or port 465 with SSL. Make sure the server allows sending from the address you plan to use as the sender.
Step 2: Add the SMTP provider to your Appwrite project
For this step, you must create an account on Appwrite Cloud or self-host Appwrite if you haven't already. In your Appwrite project, head to Messaging > Providers, click Add provider, and choose Email. Give your provider a name, choose SMTP, and click Save and continue.
In the Configure step, fill in the following fields:
| Field name | |
|---|---|
| Host | The server address of your SMTP provider, such as smtp.example.com. |
| Port | The port used for SMTP connections. Defaults to 587. |
| Username | Your SMTP account username. |
| Password | Your SMTP account password. |
| Encryption | The encryption used for the connection, SSL or TLS. |
| Auto TLS | Automatically uses TLS encryption when the server supports it. |
| Mailer | Optional. The value Appwrite sets in the X-Mailer header of the emails. |
| Sender email | The address emails are sent from. Your SMTP server must allow sending from it. |
| Sender name | The sender name that appears in the emails sent from this provider. |
| Reply-to email | The reply-to email that appears in the emails sent from this provider. |
| Reply-to name | The reply-to name that appears in the emails sent from this provider. |
Click Save and continue to enable the provider.
Step 3: Test the SMTP provider
Before you proceed, you must already have at least one topic or target set up.
Go to Messaging > Messages, click Create message, and choose Email. Write a test message, select one of your test targets, set the schedule to Now, and click Send. Check that the email arrives in your inbox. If it doesn't, check the logs in the Appwrite Console and on your SMTP server.
To send emails from your backend instead, follow the Send email messages guide with an Appwrite Server SDK.
Read more about SMTP and Appwrite Messaging
If you would like to learn more about SMTP and Appwrite Messaging, we have some resources that you should visit:
