November Happy Hour will be moved to Thursday December 5th.

Mari Jørgensen
Oct 12, 2012
  5269
(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
Optimizely SaaS CMS + Coveo Search Page

Short on time but need a listing feature with filters, pagination, and sorting? Create a fully functional Coveo-powered search page driven by data...

Damian Smutek | Nov 21, 2024 | Syndicated blog

Optimizely SaaS CMS DAM Picker (Interim)

Simplify your Optimizely SaaS CMS workflow with the Interim DAM Picker Chrome extension. Seamlessly integrate your DAM system, streamlining asset...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Optimizely CMS Roadmap

Explore Optimizely CMS's latest roadmap, packed with developer-focused updates. From SaaS speed to Visual Builder enhancements, developer tooling...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Set Default Culture in Optimizely CMS 12

Take control over culture-specific operations like date and time formatting.

Tomas Hensrud Gulla | Nov 15, 2024 | Syndicated blog

I'm running Optimizely CMS on .NET 9!

It works 🎉

Tomas Hensrud Gulla | Nov 12, 2024 | Syndicated blog

Recraft's image generation with AI-Assistant for Optimizely

Recraft V3 model is outperforming all other models in the image generation space and we are happy to share: Recraft's new model is now available fo...

Luc Gosso (MVP) | Nov 8, 2024 | Syndicated blog