SendGrid is pretty great. With just a few clicks you can essentially create an SMTP email sending server as a service.

As great as that is, my work requirements demanded the need for send history, resending emails, and read receipts. Luckily SendGrid has all of this but doesn't keep the history forever. Further, it isn't in the most usable format for data analytics.

Thats where some other really great Azure services come in handy.

  • First I set up a SQL Server DB as a mail queue. This contains both the emails, their send variables, and attachments.
  • Second I set up a powershell script run by a SQL Agent to send the messages via sendgrid
  • Third I created an Azure Function as a listener for events that SendGrid fires off. Whenever I get one of these events I write it back to the SQL server in a history table.
  • I'd like to add a UI on top that has single click resending options and even the ability to edit emails waiting in the queue that will send on a future date.
  • It would also be nice to have a toggle switch to hold back and then later release emails to be sent after review by a Business Analyst

I created this to make troubleshooting emails easier. It ended up becoming one of my most valuable tools. Too often business users would ask why they didn't get some particular email or why someone wasn't CC'd. With this, not only did I now have a complete history, I could get the exact return from the receiving server in the case that the email was actually rejected. This actually led to me adding all sorts of email domain verification to prevent getting rejected by spam filters. But thats another story.