Monday, 11 September 2017

Sending Responsive Email Template using Rails and Postmark

Sending a responsive email template and Need to watch https://www.driftingruby.com/episodes/mail-previews-and-templates Get some template here http://foundation.zurb.com/emails/email-templates.html add this in your gem file

gem 'premailer-rails'
gem 'postmark-rails', '~> 0.15.0'


To make the postmark use environment variables please follow this steps Comment out the default "from:" in ApplicationMailer To create an environment variable

nano ~/.bashrc
and add this line

export POSTMARK_API_TOKEN=b998c489-82e9-46a6-bc43-eb6c8fcc31c4
export POSTMARK_DEFAULT_FROM='postmark_registered_email'
in your secrets.yml

production:
  admin_name: <%= ENV["ADMIN_NAME"] %>
  admin_email: <%= ENV["ADMIN_EMAIL"] %>
  admin_password: <%= ENV["ADMIN_PASSWORD"] %>
  email_provider_username: <%= ENV["SENDGRID_USERNAME"] %>
  email_provider_password: <%= ENV["SENDGRID_PASSWORD"] %>
  domain_name: <%= ENV["DOMAIN_NAME"] %>
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
  site_title: <%= ENV["SITE_TITLE"] %>
  site_description: <%= ENV["SITE_DESCRIPTION"] %>
  postmark_api_token: <%= ENV["POSTMARK_API_TOKEN"] %>
  default_from_email: <%= ENV["POSTMARK_DEFAULT_FROM"] %>

in your application.rb add this lines

 config.action_mailer.delivery_method = :postmark
 config.action_mailer.postmark_settings = { :api_token => Rails.application.secrets.postmark_api_token }
 config.action_mailer.default_options = { from:  Rails.application.secrets.default_from_email }

Share:

0 comments:

Post a Comment

Popular Posts

Recent Posts

Pages

Powered by Blogger.

About Me

My photo
For the past 10 years, I've been playing with codes using PHP, Java, Rails. I do this for a living and love new things to learn and the challenges that comes with it. Besides programming I love spending time with friends and family and can often be found together catching the latest movie or planning a trip to someplace I've never been before.