/ gem

Send email from application via postmark

Postmark is widely used email delivery service for the web application. The “Postmark-Rails” Gem is a drop-in plug-in for ActionMailer to send emails via Postmark.

Links: Postmark-app(Postmark-app) , Postmark-rails gem(Github Doc) , Postmark Developer’s Blog(Postmak Blog)

To integrate it with your application:

  1. Create an account on postmark.com (it also provides free account), set your-email as sender’s signature. This email-signature only you can use to send email, by setting it in from address.

  2. In you environment files: (staging/ production)

POSTMARK_API_KEY = your_postmark_api_key
config.action_mailer.delivery_method = :postmark
config.action_mailer.postmark_settings = { :api_key => POSTMARK_API_KEY }
  1. for development environment:
    On local, the postmark has to be integrated with smtp.
    (also make sure to enable SMTP from your postmark account settings)
POSTMARK_API_KEY =  your_postmark_api_key
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address              => "smtp.postmarkapp.com",
  :port                 => 25,
  :domain               => 'abcd',
  :user_name            => POSTMARK_API_KEY,
  :password             => POSTMARK_API_KEY,
  :authentication       => 'plain',
  :enable_starttls_auto => true  }
  1. In your gemfile,
gem 'postmark-rails', "~> 0.5.2"
  1. To send email, from your action-mailer class
    The email_address given in the “from” field should be same as your email-signature set in your postmark-account.
mail(
  to:       email_address,
  from:     email_address,
  subject:  subject,
  reply_to: email_address,
  tag:      "tag_name")

Features of postmark:

  1. Send attachments with email
    http://developer.postmarkapp.com/developer-build.html#attachments

  2. Tagging emails: with the help of tag assigned to email of different types of email you send it helps us to review statistics.

  3. Bounced emails: Postmark gives the details of bounced-emails , categorized with different types of bounce like Hard-bounce(invalid email), Transient (not-delivered due to network issue) and many more.
    http://developer.postmarkapp.com/developer-bounces.html

Postmark.api_key = POSTMARK_API_KEY
all_bounce_records = Postmark::Bounce.all

this will give list of all bounced emails, that are failed to receive email sent from our application.

The Postmark is the most preferable as its tagging and bounce feature are very handy which can be used as core in any web application.
[Check Here..(why Postmark?)][4]

Swati Jadhav

I am a Rubyist, ROR developer, passionate about change and trying new things, both professionally and in general with life. Currently, working on Ember.js applications and fasci...

Read More