Mari Jørgensen
Oct 12, 2012
  5186
(1 votes)

Improve email delivery by integrating EPiServer with Postmark

Guaranteeing email delivery is not an easy task. There are many variables involved that could prevent your emails from being delivered. You don’t know if they are bouncing, ending up in the spam folder or just failing altogether.

If email communication is essential for your site or application,  it is a good idea to leave it to the professionals.

Postmark is a service that any developer can use to ensure the correct delivery of transactional mail – and you set it up in less than 5 minutes.

Getting started

  • Create an account
  • Create a new virtual server (one for each web application)
  • Add sender signatures (from addresses that are verified)

I would also recommend that you setup email authentication for your DNS records, as this will be a major benefit. Email authentication is a way to tell receiving mail servers (Gmail, Yahoo, etc.) that Postmark (or anyone else specified) is allowed to send for your domain.


Using it in your application

You can install a Postmark .NET library using nuget:

nugetpck

Below is a simple example of how you can use the API. In addition to support for async sending, Postmark exposes bounces over a REST-based API, a hook URL for inbound emails (JSON POST data) and can be configured using smtp. Visit http://developer.postmarkapp.com/ to get a complete list of functionality.

public bool SendMail(string toAddress, string subject, 
string mailBodyText, string htmlBody) { // server token is API key generated when setting up postmark server string my_server_token = GetPostmarkServerToken(); PostmarkMessage message = new PostmarkMessage { // the signature address used when setting up your server
From = GetSignature(), To = toAddress, Subject = subject, HtmlBody = htmlBody, TextBody = mailBodyText }; _log.Debug(string.Format("Trying to send mail to '{0}' through Postmark service",
toAddress)); PostmarkClient client = new PostmarkClient(my_server_token); PostmarkResponse response = client.SendMessage(message); if (response.Status == PostmarkStatus.Success) return true; _log.Debug(string.Format("Failed to send mail to '{0}' through PostMaster.
Postmark response is {1}."
, toAddress, response.Status)); return false; }

In our solution we used Postmark for sending emails related to user registration and password reset.

Keep in mind

  • Postmark is for transactional email only, not for newsletters or other bulk email
  • Maximum size is 10mb
  • Review list of accepted file types to make sure your attachments are accepted
  • Maximum recipients for each email is 20
Oct 12, 2012

Comments

Please login to comment.
Latest blogs
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024