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-rails gem , Postmark Developer’s 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 }

3. 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  }

4. In your gemfile,

gem ‘postmark-rails’, “~> 0.5.2”

5. 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..
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s