Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
May 11, 2021 02:53 pm GMT

30DaysOfAppwrite : Getting Started with SMTP

Intro

#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 setup 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 a SMTP Relay under Email API -> Integration Guide and create an API Key.

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

Configuration

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:

NameDescription
_APP_SMTP_HOSTSMTP server host name 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_PORTSMTP server TCP port. Empty by default.
_APP_SMTP_SECURESMTP secure connection protocol. Empty by default, change to 'tls' if running on a secure connection.
_APP_SMTP_USERNAMESMTP server user name. Empty by default.
_APP_SMTP_PASSWORDSMTP 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.

_APP_SMTP_HOST=smtp.sendgrid.net_APP_SMTP_PORT=587_APP_SMTP_SECURE=tls_APP_SMTP_USERNAME=YOUR-SMTP-USERNAME_APP_SMTP_PASSWORD=YOUR-SMTP-PASSWORD

After you 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

Thats it!

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

If everything went well, you should receive an E-Mail with instructions to reset your password. Obviously this is not necessary and 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 account with the associated email address.

Credits

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


Original Link: https://dev.to/appwrite/30daysofappwrite-getting-started-with-smtp-1e2e

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To