postmark-rails

Set up postmark-rails
Icons/chart bar
Used 1 time
Created by
A Andy Waite

Usage
https://github.com/wildbit/postmark-rails

For Rails 6 or newer.

Run this command in your Rails app directory in the terminal:

rails app:template LOCATION="https://railsbytes.com/script/z0gs9Q"
Template Source

Review the code before running this template on your machine.

gem "postmark-rails"

run "bundle exec rails secret"

if yes?('Do you wish to add a Postmark API token? It should be in the form `postmark_api_token: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`')
  run "rails credentials:edit"
end

application do
  "config.action_mailer.delivery_method = :postmark"
  "config.action_mailer.postmark_settings = { api_token: Rails.application.credentials.postmark_api_token }"
end


require 'postmark-rails/templated_mailer'

if yes?("Do you wish to set up a templated mailer?")
  file "app/mailers/postmark_mailer.rb", <<~CODE
    require "postmark-rails/templated_mailer"

    class PostmarkMailer < ApplicationMailer
      include PostmarkRails::TemplatedMailerMixin
      
      def welcome
        self.template_model = {}

        mail(
          to: "[email protected]",
          from: "[email protected]",
          track_opens: "true",
          message_stream: "outbound"
        )
      end
    end
  CODE
end
Comments

Sign up or Login to leave a comment.

© 2022 GoRails, LLC