Skip to content

hansenms/mailq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Azure Storage Mail Queue Processor

This repository contains a simple service that can be used to process serialized System.Net.Mail.MailMessage objects from an Azure Storage Queue. The applications and utility library are written using .NET Core 2.0.

When organizations move web applications to the cloud, they often look to hosting environments such as Azure Web Apps. A Web App will typically not have access to the on-prem network unless steps are taken to connect it using either an App Service Environment or Web App Virtual Network integration in combination with Express Route or VPN connection. Often the applications will need to send email to users and when the applications were hosted on-prem, it was possible use a locally configured SMTP relay. In the cloud, the application may not have access to this relay and a simple task like sending email becomes more complicated. There are tools such as SendGrid that can be leveraged but for some organizations (e.g., Government Agencies) use of such services may break compliance with TIC rules.

Another option is to have the Web App enqueue mail messages on a storage queue in the cloud and have an application on-prem do the actual sending of emails through the local SMTP server. The application in this repository does just that.

The MailQ application is available as Docker image and it can be run with a command line:

docker run -e ConnectionString='<Azure Storage Account Connection String>' -e MailQueueName='<Name of Queue>' -e SmtpServer='<SMTP domainName>' hansenms/mailq

There are several ways it can be deployed. One option would be to run this Docker container directly on the on-prem network, another would be in a virtual network that is peered with the on-prem network through VPN connections or Express Route. The illustration below shows both options.

Topology

Once the MailQ service is deployed you can use the MailSender test application to send an email to the storage queue. You will need to set the following environment variables: ConnectionString, MailQueueName, and SmtpServer. You can run the client with:

cd MailSender
dotnet run

You will be prompted for email addresses, subject and message body.

Both the MailQ service and the MailSender test application use a SerializeableMailMessage class, which I found here and I made a few modifications to it. This class is used to serialize and deserialize System.Net.Mail.MailMessage objects.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages