Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Mari Jørgensen
Oct 12, 2012
  5157
(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
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog