How to Send Emails Using a Third-Party Provider in Appwrite

Hemant SharmaHemant Sharma
4 min read

When you are developing your application using Appwrite as your BaaS, you will have situations where you will be needing to send emails to your users. Appwrite has a feature called “Messaging“ for this situation where you can setup your mail server into Appwrite as you mail provider and use it to send mails to your users.

Let’s understand how this works

Follow these steps to get to the feature

  1. Go to your Appwrite Admin Console here and go to your specific project you wish to use the messaging feature in

  2. Go to your project and there you will find a sidebar with some options in it, it should look like this, and go to the option “Messaging“.

  3. Now this is the Messaging section, here you will have all the settings and features to manage everything related to emails, push notifications and SMS to your users.

There are a few terminologies which you will need to understand before we start.

Messages

Messages are the section that keep a log and history of all the messages sent to your users through Appwrite be it Emails, Push Notifications and SMS.

Topics

Topics are used to deliver messages to groups of users at once. Let’s say that you wish to target a specific group of users, let’s say the users using any paid plan of your app, only those users needs to receive the mail, here in topics you can manage it accordingly.

Providers

Providers are the mail servers that you are using to send emails, these providers such as Zoho, you will be setting up here and using here in Appwrite to allow Appwrite to send emails to your users.

Setup Third-Party Email Provider in Appwrite

In order to setup a third-party provider in Appwrite, we will have to go to the Providers tab and click on the Create Provider button as shown below and select the option Email

Then you will be taken to a new page, there you will have to setup your provider by providing the details, add a name to your provider details and select the option SMTP (Generic SMTP server) and click Next.

After this we will be taken to the next step into the settings section, here we will have to be setting up the rest of the required details of the mail hosting server. In my case, I am using Zoho Mail as my SMTP server, so I will be filling in the details accordingly, you can simply Google your mail provider details and fill it up here.

You also need to fill up the Sender email and name, this will be the mail ID you wish to use to send the mails from your mail server and then click on the Create Button.

Now you will have a mail provider created for your Appwrite Messaging service and it should be looking like this in your console window

Send Emails from the Third-Party Email Provider using Appwrite

Now that we have setup our third-party email provider in Appwrite, we can use this to send emails to our users. Let move to the Messages tab in the console and create and send a new message to our user. Click on the Create message Button and select the Email option from there

Here we can write out email, we can also send HTML based mails to our users for better UX and a great reach. Let’s user HTML mode to send our first test email.

Click on Next, and in the next step, we have the option of selecting our targets. Targets are basically the users to whom you wish to send the email to using the option Select targets

so we simply select a user and click on Add

and click on Next, in the next page we will be asked to select a schedule when to send the message, since this is a test email, we can simply send this email to our users immediately, do note that This action is irreversible.

Your email will be scheduled into processing immediately by Appwrite servers. Since I sent this mail to my own email, we can see that I received the email exactly how I sent it!

Connect with me on 𝕏, LinkedIn, GitHub and hemantsharma.tech

I h*ope you found this blog post helpful. Stay tuned for more posts!🙌*

Hope this blog was helpful to you, Please like the blog and write your valuable comment below, you can also ask any queries you have.

0
Subscribe to my newsletter

Read articles from Hemant Sharma directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Hemant Sharma
Hemant Sharma

Full Stack Developer | SvelteKit, Next.js, Node.js, Java, DSA, SQL, MongoDB | Building Web Apps to Implement Services #fullstack #developer #engineer