Integrate Sendgrid to send Email Notifications

Reading time: 5 mins

Before you begin, please make sure you have a Weavy backend site up and running.

Introduction: What are Email Notifications?

Email Notification is one daemon process (background job that runs periodically) that you can check by navigating to <your-weavy-url>/manage/daemons and click on Email notifications. Every direct message the user receives which is not read and other thread notifications are delivered to user's inbox. The image shows an example of notifications. 

This tutorial will use Sendgrid as an example.

Setting up Sendgrid Account

  1. Sign up for a SendGrid account
  2. Create and store a SendGrid API key with full access "Mail Send" permissions.
  3. Verify your Sender Identity

Setting up Weavy backend

Configuration with web.config

Most commonly, settings are defined within the appSettings element in web.config, but there are also other ways to configure settings. You need to specify few details such as:

weavy.smtp-from The email address from which you verified Sendgrid Sender Identity.
weavy.smtp-password The Sendgrid API KEY.
weavy.smtp-port Please read below section to specify port.
weavy.smtp-server smtp.sendgrid.net
weavy.smtp-username apikey


 

<appSettings>

  <add key="weavy.smtp-from" value="your-mail-id" />

  <add key="weavy.smtp-server" value="smtp.sendgrid.net" />

  <add key="weavy.smtp-port" value="25" />

  <add key="weavy.smtp-username" value="apikey" />

  <add key="weavy.smtp-password" value="your-sendgrid-api-key" />

  <!-- etc -->

</appSettings>

Sendgrid SMTP ports

Rebuild Solution

To see your changes in effect, save the changes made, rebuild your weavy solution and start without debugging. 

Test your Email Notifications

Once you start the local server again, navigate to https://localhost:44323/manage/tools and click on Email test and hit on Run. You should see a screen something like this

Check your mail box with which you have registered on weavy and you should see an email like this

Congratulations, you just rocked!
You can integrate any SMTP servers in similar fashion, if you need SSL connection, you can add the key weavy.smtp-ssl and set it's value to true inside the configuration file. 

Visit Developer Portal for more such tutorials!