Rails::Reply via Email::Using Postmark

Sending emails from rails is an easy process. But sometimes we need to reply to the email itself that was sent by the app.

Postmark is the easiest and most reliable way to be sure your important transactional emails get to the inbox. Postmark allows you to send your application’s emails with high delivery rates, including bounce/spam processing and detailed statistics. In addition, Postmark can parse incoming emails which are forwarded back to your application.

The process of replying via email is known to be inbound.

How to implement Postmark in rails?

  1. Add add-on postmark in your Heroku or  sign up using https://account.postmarkapp.com ( If you add postmark as an add-on in Heroku you do not need to sign up additionally).
  2. Create your server by adding the name of the server.
  3. You can create a signature or even skip this step.
  4. Since we are implementing inbound process, we will need our server’s inbound email address which can be found on the “Process inbound email” tab.                                         Screenshot from 2016-06-29 21:47:08.png
  5. Now you need to set `reply_to` (when sending email) with the given inbound email address (see example below).
  6. And at last you need to give the callback url. Postmark post JSON data each time an inbound event occurs (see screenshot below). In this callback portion, one can perform any necessary actions needed.

Example:

mail( to: <receiver's email>,
 subject: <subject>,
 reply_to: <server's inbound email address>)

Screenshot:

Screenshot from 2016-06-29 22:02:17

Postmark also keeps tracks of the emails whether it is inbound or outbound. So you can check whether the email are being successfully processed or not.

NOTE::

If we need to send some important information that is required when the receiver replies the email s/he received, then we can add that information after a `+` sign in the `server’s inbound email address`.

Example:

3e5317xxxx48ce3bxxxx1a7be74f665f+message78@inbound.postmarkapp.com

Let’s say I need the `message_id` . Hence, I will add `+message<MESSAGEID>` or just `+<MESSAGEID>` to the email address. This additional details will appear in the JSON data under `MailboxHash` in the callback url we set in the server.

References:

http://developer.postmarkapp.com/

https://devcenter.heroku.com/articles/postmark

https://github.com/wildbit/postmark-gem

 

Advertisements

One thought on “Rails::Reply via Email::Using Postmark

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