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:
-
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.
-
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 }
- 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 }
- In your gemfile,
gem 'postmark-rails', "~> 0.5.2"
- 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:
-
Send attachments with email
http://developer.postmarkapp.com/developer-build.html#attachments -
Tagging emails: with the help of tag assigned to email of different types of email you send it helps us to review statistics.
-
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.