Seq.App.EmailPlus-Enhanced available!

Table of Contents

Email+ (aka HTML Email)

I have had some pull requests open for a while for Seq.App.EmailPlus, which are quite large in scope and degree of change. This is because they are transformational in nature - adding fallback mailhosts, delivery using DNS resolution, fine-grained TLS control, enhanced logging, and adding a number of new envelope options - CC, BCC, ReplyTo, and Priority. It also allows specifying a plain text alternative body, which is useful for mail recipients who (for whatever reason) can't display HTML.

I previously incorporated much of this into Lurgle.Alerting, because it makes this a full featured mail library that can provide full features without needing to code them for individual apps. This was also a useful way to test the functionality outside of Seq.App.EmailPlus, to ensure that everything worked "as advertised". 

The pull requests are taking some time for the team to get to - understandably so, given their size. I finally hit production use cases for the enhancements though - we needed reliability in mail delivery (using the fallback mail hosts), priority, a reply to address, and as a nice-to-have, using the CC field.

This pushed me to make a dev build available via Nuget, as "HTML Email Enhanced Edition".

 

Features and Enhancements:

  • Adds the ability to specify multiple mail hosts, as a comma-delimited string
  • Adds the ability to deliver using DNS resolution for remote mail hosts (direct delivery). This can operate as the only delivery method, or as a fallback method if all mail hosts are unavailable
  • Email send results are logged with structured properties to allow monitoring and alerting
  • Fine-grained control over MailKit SSL/TLS options via drop down list (None, Auto, SslOnConnect, StartTls, StartTlsWhenAvailable)
  • Specify email priority (High, Normal, Low)
  • Optionally map email priority to a property from the log/alert initiating the email - eg. If @Level is Error, Priority is High
  • Add CC, BCC, and ReplyTo fields with Handlebars template
  • Add optional plain text alternate body template

 

Let's dig into this a bit further.

HTML Email Enhanced Edition - Delivery, Envelope, and TLS

The first set of enhancements for Email+ revolved around SMTP delivery - allowing for fallback mail hosts in the event that the primary SMTP host is unavailable, and allowing for delivery using DNS resolution of remote mailhosts (looking up the MX record for destination domains). 

The DNS delivery option also acts as a final fallback to the mail host if both are configured.

Following on from this, I integrated the ability to specify CC, BCC, and ReplyTo fields. These are useful to have available - I had a specific case where ReplyTo was essential - and I've made them support Handlebars syntax like the To field already did.

I also enhanced the TLS configuration. Did you know Seq supports dropdown lists if a field is an enum? I didn't, until Nick Blumhardt pointed it out ... but it made this an absolute cinch. I can simply list all options available from the underlying MailKit library - which allows resolving a known issue with the in-dev builds of Email+ that don't like self-signed or invalid certificates, because you can always specify None or another suitable behaviour.

Plain text alternate bodies

The next addition was the option for an alternate plain text template. This is a really straightforward addition. It's generally considered that well structured HTML emails will include an alternate plain text body. This makes it easy to do, by supporting Handlebars in the same way as the normal HTML body. If it's not configured - it's not used.

Email Priorities and mapping 

Finally, I got a bit funky with adding email priority. Here was an opportunity to allow a limited degree of interoperability with other apps, by optionally allowing a mapping between a structured property and the email priority, with a fallback/default priority if that mapping fails. This is a similar Key=Value comma-delimited string as has been implemented with apps such as Seq.App.OpsGenie and Seq.App.Atlassian.Jira, along with the EventX Trilogy apps.

Obviously you can still specify just a static Priority (High, Normal, or Low) in the Email Priority or Property Mapping field. It will default to Normal if not configured.

But if you want to get fancy - here's a sample of mapping @Level to email priority!

Enhanced Logging

Who could forget the logging enhancement! It puzzled me that Email+ didn't actually log the fact that it sent an email, and I suspect in at least some cases that it may not actually log failures - I've only observed that in production where some emails simply didn't send at all, and I had no way to trace back to what happened. This should always be logged, and better yet - with good structured properties that tell you exactly what's going on! Failed to send after multiple tries? We'll keep all those errors. What was the email envelope and body? Got you covered. 

This builds an ability to monitor and alert on emails from Seq - something I've found incredibly valuable with all the other capabilities I've built in our implementation. You should see some of my cool dashboards!

 

Get it for testing now!

The main purpose for publishing this was both to allow testing of the features while the Email+ pull requests are pending review, but also to solve a real-world problem that I was facing. If you'd like to test the HTML Email Enhanced Edition, feel free - you can install it to Seq using the Nuget package ID Seq.App.EmailPlus-Enhanced, and it will happily run alongside an existing Seq.App.EmailPlus install! And, of course - happy to get any feedback!

 

 

Comments

You may also like:

DST update for EventX Trilogy for Seq now available!

While I was investigating a case where Event Schedule for Seq had duplicate multi-log events occurring, I noticed a Daylight Savings Time issue with the unit tests, which was evident due to an upcoming DST changeover here in Australia. It was readily apparent, of course, that with their shared DNA,...