Coder Social home page Coder Social logo

postmark-rails's Introduction

Postmark Logo

Postmark Rails Gem

CircleCI Code Climate License Gem Version

Postmark allows you to send your emails with high delivery rates. It also includes detailed statistics. In addition, Postmark can parse incoming emails which are forwarded back to your application.

The Postmark Rails Gem is a drop-in plug-in for ActionMailer to send emails via Postmark. The gem has been created for fast implementation and fully supports all of Postmark’s features.

Usage

Please see the wiki for detailed instructions about library features. For details about Postmark API in general, please check out Postmark developer docs.

Requirements

You will need a Postmark account, server and sender signature (or verified domain) set up to use it. For details about setup, check out wiki pages.

Also you will need a postmark gem version 1.0 and higher is required.

Supported Rails Versions

  • Rails 7.0
  • Rails 6.0
  • Rails 5.0
  • Rails 4.x
  • Rails 3.x

For Rails 2.3 please take a look at version 0.4. It may miss some new features, but receives all required bug fixes and other support if needed.

Installation

Add postmark-rails to your Gemfile and run bundle install.

gem 'postmark-rails'

Rails 6-7

Save your Postmark Server API Token to config/credentials.yml.enc:

run rails secret, then run rails credentials:edit and add:

postmark_api_token: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

Set Postmark as your preferred mail delivery method via config/application.rb:

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

Rails 3-5

Save your Postmark Server API token to config/secrets.yml.

postmark_api_token: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

Set Postmark as your preferred mail delivery method via config/application.rb:

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

Note: The postmark_settings hash can contain any options supported by Postmark::ApiClient.

Additional information

Looking for the advanced usage examples? Check out the documentation for the postmark gem. The postmark-rails gem is built on top of it, so you can benefit from all it's features.

Note on Patches/Pull Requests

See CONTRIBUTING.md file for details.

Authors & Contributors

  • Artem Chistyakov
  • Petyo Ivanov
  • Ilya Sabanin
  • Hristo Deshev
  • Randy Schmidt
  • Chris Williams
  • Nicolás Sanguinetti
  • Laust Rud Jacobsen (rud)

Issues & Comments

Feel free to contact us if you encounter any issues with the library or Postmark API. Please leave all comments, bugs, requests and issues on the Issues page.

License

The Postmark Rails gem is licensed under the MIT license. Refer to the LICENSE file for more information.

Copyright

Copyright © 2022 ActiveCampaign LLC.

postmark-rails's People

Contributors

amanshin avatar balvig avatar bensie avatar damhonglinh avatar empact avatar foca avatar greysteil avatar hdeshev avatar ibalosh avatar irmiller22 avatar isabanin avatar jvans1 avatar langalex avatar mattbrictson avatar neomindryan avatar petyosi avatar richardmarbach avatar temochka avatar tomazy avatar tomek-ac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

postmark-rails's Issues

postmark_attachments broke with Rails 3.2.13 update

After updating the the latest Rails (3.2.13) attachments stopped working. I have verified this is the case both running the app and in the specs.

Basically I see:

message = mail(... :postmark_attachments => [a_file_here], ...)
message.postmark_attachments #=> []

Attachments not working after upgrading to rails 3.2.13

Just upgrade our rails app to 3.2.13 and we noticed that attachments are not being added to the email. No error was generated when you try to send an email with attachment. Reverting back to rails 3.2.12 and tried to send an email with attachment and it works as expected.

rails 3.2.13
postmark 0.9.19
postmark-rails 0.4.1

Unable to tag emails

I have tried to tag email as specified in the gem readme file.
But when I retrieve the list of bounced emails from the postmark API it shows the tag as nil for all the bounced email records.

Missing dependancy on 'postmark' gem

I assumed putting 'postmark-rails' in my gem file would be enough, but it seems I also need to put 'postmark' in too. I can't think of a situation when you'd want this without the other gem.

No error message

When trying to send email through this gem, in my production.log, it said that an email was sent.

However, postmark never showed the message. I changed some stuff back to get it to work again, but no error was thrown.

If the email has problems sending, where will they be logged?

undefined method `postmark_settings=' on Heroku deployment

Hi,

I'm getting undefined method 'postmark_settings=' when trying to deploy to Heroku for staging app.

Here's the app info:

Ruby 2.0.0
rails  4.1.0
postmark 1.7.0
postmark-rails 0.12.0

Here are the relevant changes:
Gemfile:
gem 'postmark-rails', group: :production
config/environments/staging.rb (breaks on the second line):

  config.action_mailer.delivery_method   = :postmark
  config.action_mailer.postmark_settings = { api_token: ENV['POSTMARK_API_TOKEN'] }
  config.action_mailer.default_url_options = { host: "#{ENV['APP_NAME']}-staging.herokuapp.com" }

The error happens during git push to heroku during rake assets:precompile. I assume that's the first time when the app is loaded. I can see in the output earlier that postmark and postmark-rails gems were successfully installed.

PS Is there any updated guide as to how setup Postmark addon on Heroku? The guide on Heroku website is a bit outdated (no mention of Rails 4):
https://devcenter.heroku.com/articles/postmark

Thanks!

Do we call deliver or deliver! method

Hi using the new gem for support of Rails 3, I can't send email using deliver() method. Do we need to use deliver!() instead?

TechReportMailer.alive.deliver!

rather than

TechReportMailer.alive.deliver

Exception handling with DelayedJob

I've been reviewing issue #19 to clear up the best way to handle postmark exceptions. I thought I'd found the answer I was looking for but it seems i'm only halfway there. As @dgilperez points out the suggested code does work but doesn't seem to work with in conjunction with delayed job.

I believe this will probably be something we need to address with delayed job but thought I'd see if the postmark team had any thoughts or fixes for the issue before I got to far down the rabbit hole.

The following is working for me without DelayedJob in the workflow.

class ApplicationController
  rescue_from Postmark::InvalidMessageError, :with => :handle_email_error

  def handle_email_error
    # Handle exception here
  end
end

Do not throw exceptions that code cannot handle

I have noticed that postmark throws exceptions like this

"Postmark::InvalidMessageError - You tried to send to a recipient that has been marked as inactive"

However, there is not much that the code can do to recover from this error. As a result, it just propagates and creates lots of noise. I understand that some people would want to see these exceptions and perhaps use or handle them, so I think a great alternative would be to provide an option toggle raising exceptions or not

Rails 6.0

Hello!

It seems like you are not officially supporting Rails 6.0 (couldn't find any mention of it in the codebase + you don't test against it). Do you plan to offer 6.0 support? Do you think it will be safe to include this gem regardless?

Thanks! 👋

Is rescue_from for Rails 5 actually working?

Hi,

I have setup rescue_from at my ApplicationMailer as per the recent README. Whilst normal raise inside the mailer action will go to the rescue_from handler, all PostMark's error will not.

class ApplicationMailer < ActionMailer::Base
  # I am using StandardError which I believe Postmark::InactiveRecipientError inherit from
  rescue_from StandardError, with: :log_mailer_error
end

# At the mailer, normal raise will get caught, but not Postmark::InactiveRecipientError
class HelloMailer < ApplicationMailer
  def send_test(msg)
    mail(to: ...)
    raise 'something wrong' # this will get caught by rescue_from
  end
end

Is it because PostMark gem need to include ActiveSupport::Rescuable and make use of this method (rescue_with_handler) in order to take advantage of rescue_from?

Should postmark's api key be set in an initializer file?

It seems odd to be setting API keys in application.rb. Most gems do their configuration in a file like config/initializers/postmark.rb.

Setting config.action_mailer.delivery_method = :postmark in production.rb or development.rb makes sense though :)

:track_opens => true not setting header correctly?

Readme says to pass :track_opens => 'true', however when I do that, the header comes out as:

Track-Opens: true

Postmark.app says that I have not enabled tracking, so I suspect that dash is causing the issue and it should be TrackOpens: true.

Figure a way to get the message ID

Postmark returns a message ID after it accepts an email that you can use when tracking delivery -- see if and when a message got sent, did it bounce, etc. We need a way to return that after calling

Mail.delivery_something(...)

Why was 0.5.0 yanked from rubygems.org?

Hi,

It seems that postmark-rails 0.5.0 was recently yanked from rubygems.org. This unexpectedly broke one of our production deployments because our Gemfile.lock was pointing to 0.5.0.

I can understand pulling a gem if there is a critical security vulnerability, but was that the case here?

How to handle exceptions?

Related #19 and #35

We are running on Rails 4.2.4. We are trying to figure out how to properly handle delivery errors (such as Postmark::InvalidMessageError) properly, with and without ActiveJob (which, in our case, is backed by DelayedJob).

class UserMailer < ActionMailer::Base
  def welcome(email)
    mail to: email, subject: 'Welcome!'
  end
end

Running UserMailer.welcome('[email protected]').deliver will, of course, raise the Postmark::InvalidMessageError. But how do we handle that? The other issues point to a flow where the mail call is wrapped into a begin rescue block, but that doesn't work because the mail just returns the message object and the actual delivery is done somewhere else (thus the rescue doesn't catch anything).

Next, we tried

class UserMailer < ActionMailer::Base
  around_action do |mailer, block|
    begin
      block.call
    rescue Postmark::InvalidMessageError => e
      puts "#{e}"
    end
  end

  def welcome(email)
    mail to: email, subject: 'Welcome!'
  end
end

But still no luck. The reason is probably the same as before: block.call will simply call welcome which returns the message object and the delivery is actually done outside of this chain.

Wrapping the original call solves the problem:

begin
  UserMailer.welcome('[email protected]').deliver
rescue Postmark::InvalidMessageError => e
  puts "#{e}"
end

But we don't obviously want to wrap every call like this - and - in reality, we really use deliver_later to push it via ActiveJob to the background (DelayedJob). This is currently the best solution we could come up with. It uses a simple proxy class:

class MailerJob < ActiveJob::Base
  queue_as :default

  # Example how to handle other errors
  rescue_from(ActiveJob::DeserializationError) do |e|
  end

  def perform(message)
    begin
      message.deliver_now
    rescue Postmark::InvalidMessageError => e
      # somehow set the user(s) emails to inactive in the database
    end
  end
end

MailerJob.perform_later(UserMailer.welcome('[email protected]'))

This feels a bit patched and I'm certain we've overlooked a much simpler solution here. Please advice!

Update: Unfortunately the MailerJob approach doesn't work because ActiveJob doesn't know how to serialize ActionMailer::MessageDelivery or Mail::Message. I guess we could do something like MailerJob.perform_later(UserMailer, :welcome, '[email protected]') instead.

How do I configure postmark-rails to use secure connection?

I see in the documentation that I should initialize postmark gem like so:

config.action_mailer.delivery_method = :postmark
config.action_mailer.postmark_settings = { :api_key => "your-api-key" }

I also see that the docs indicate I can use the secure endpoint with this:

client = Postmark::ApiClient.new(your_api_key, secure: true
http_open_timeout: 15)

But I'm using a standard configuration for RoR 4, and I simply want to use the gem. How do I configure config.action_mailer.postmark_settings to indicate that I should use the secure endpoint? This isn't clear in the docs.

Thanks.

Postmark wants to auto install in Rails 2 modus

I had a working setup but now my code is failing.
My email functionality doesn't work any more ( since updating to Rails 3.2.12? ).
I traced the culprit, it's the auto detect and install process.
It believes it's running in a Rails 2 env.

I am absolutely certain I'm running Rails 3+.

# postmark-rails.rb
def auto_detect_and_install
    if ActionMailer::Base.respond_to?(:add_delivery_method)
      install_in_rails_3
    else
      # postmark rails wants to install in rails 2 modus ...
      # triggering the error you see below
      install_in_rails_2
    end
  end

The error:

undefined method `create_mail' for class `ActionMailer::Base'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.12/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.12/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method_chain'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/postmark-rails-0.4.1/lib/postmark_delivery_method.rb:18:in `block in included'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/postmark-rails-0.4.1/lib/postmark_delivery_method.rb:17:in `class_eval'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/postmark-rails-0.4.1/lib/postmark_delivery_method.rb:17:in `included'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/postmark-rails-0.4.1/lib/postmark-rails.rb:20:in `include'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/postmark-rails-0.4.1/lib/postmark-rails.rb:20:in `install_in_rails_2'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/postmark-rails-0.4.1/lib/postmark-rails.rb:15:in `auto_detect_and_install'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/postmark-rails-0.4.1/lib/postmark-rails.rb:30:in `<top (required)>'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `each'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `block in require'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `each'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `require'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.1/lib/bundler.rb:128:in `require'
/Users/webdevotion/myproject/config/application.rb:8:in `<top (required)>'
/Users/webdevotion/myproject/Rakefile:5:in `require'
/Users/webdevotion/myproject/Rakefile:5:in `<top (required)>'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:583:in `raw_load_rakefile'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:89:in `block in load_rakefile'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:88:in `load_rakefile'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:72:in `block in run'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/bin/rake:19:in `load'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/bin/rake:19:in `<main>'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
/Users/webdevotion/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'

Doubled gem post-install message

Low importance issue: it looks like both the postmark-rails and postmark gem have the same post-install message, should postmark-rails assume that postmark will handle the messaging and just remain quiet?

> bundle install
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from postmark:

    ==================
    Thanks for installing the postmark gem. If you don't have an account, please
    sign up at http://postmarkapp.com/.

    Review the README.md for implementation details and examples.
    ==================
  Post-install message from postmark-rails:

    ==================
    Thanks for installing the postmark-rails gem. If you don't have an account, please sign up at http://postmarkapp.com/.
    Review the README.md for implementation details and examples.
    ==================
>

Update in postmark - postmark v1.0.0 breaks postmark-rails

I just updated my gemfile and I am getting a new version of postmark - v1.0.0 that breaks
postmark-rails v0.4.1

Version 0.9.8 of postmark works fine for me.
I needed to do this to fix my issue

gem 'postmark', '0.9.18'
gem 'postmark-rails', '0.4.1'

Error:
rake aborted!
uninitialized constant Postmark::AttachmentsFixForMail
/.rvm/gems/ruby-1.9.3-p286/gems/postmark-rails-0.4.1/lib/postmark-rails.rb:22:in install_in_rails_3' /.rvm/gems/ruby-1.9.3-p286/gems/postmark-rails-0.4.1/lib/postmark-rails.rb:10:inauto_detect_and_install'
/.rvm/gems/ruby-1.9.3-p286/gems/postmark-rails-0.4.1/lib/postmark-rails.rb:27:in <top (required)>' /.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:inrequire'
/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in block (2 levels) in require' /.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:ineach'
/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in block in require' /.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:ineach'
/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in require' /.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler.rb:128:inrequire'
/development/hyfn_projects/h8r/config/application.rb:15:in <top (required)>' /development/hyfn_projects/h8r/Rakefile:5:in<top (required)>'
/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/rake_module.rb:25:in load' /.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/rake_module.rb:25:inload_rakefile'
/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:589:in raw_load_rakefile' /.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:89:inblock in load_rakefile'
/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:160:in standard_exception_handling' /.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:88:inload_rakefile'
/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:72:in block in run' /.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:160:instandard_exception_handling'
/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'

Why :postmark_attachments?

Hi,
:postmark_attachments bothers me a bit. It breaks the api for ActionMailer so if I want to switch postmark in and out as a delivery I have to also modify my attachment code. A small ting but just annoying.

I wanted to understand why the "standard" attachments are not supported so I could maybe look into fixing it. What is the hurdle?

Unable to send messages using different postmark servers

I would like to send certain emails from a specific postmark "server". So, I have a method that gets called to set the ActionMailer::Base.postmark_api_key before each email goes out:

def set_mail_server(type=:account)
    case type
    when :order
      ActionMailer::Base.postmark_api_key = "1234"
    when :update
      ActionMailer::Base.postmark_api_key = "5678"
    else
      ActionMailer::Base.postmark_api_key = "9101"
    end
  end

And an example mail method:

  def invoice(invoice)
    default_options
    set_mail_server(:account)
    recipients invoice.email
    subject "Monthly Invoice"
    body :invoice => invoice
    tag "Account Invoice"
  end

The method is being called and the correct key is being set (verified via puts statements), however, Postmark actually sends from the same server if more than one message in the same request. Let's say I have 1 message from the "order" server and another from the "account" server that are sent during the same request. Postmark would send both from either the "order" or "account" server, even though I'm setting the key before each message is sent.

I've dug through the code and I can't seem to figure out where the value is being cached. I've also tried resetting the parameter to nil before setting it, but that doesn't work either.

Any ideas? Thanks!

uninitialized constant PostmarkRails::TemplatedMailer error with postmark-rails 0.19.0

Based on the wiki entry regarding the templating implementation I wrote the following

class TestMailer < PostmarkRails::TemplatedMailer
  def welcome
    mail to: '[email protected]', postmark_template_alias: 'test'
  end
end

However, when called I get a NameError (uninitialized constant PostmarkRails::TemplatedMailer).

When inheriting from ApplicationMailer and including PostmarkRails::TemplatedMailerMixin I have no such issues.

Postmark::TimeoutError

I had an error Postmark::TimeoutError

2014-06-30T09:46:10Z 11971 TID-9oues WARN: {"retry"=>true, "queue"=>"mailer", "class"=>"Devise::Async::Backend::Sidekiq", "args"=>["reset_password_instructions", "User", "3842", "4M2wYxLb-nXyJaJ1i-sX", {}], "jid"=>"b27c0259f5eee7fc7843a42b", "enqueued_at"=>1404121419.8982124, "error_message"=>"execution expired", "error_class"=>"Postmark::TimeoutError", "failed_at"=>1404121434.9381132, "retry_count"=>1, "retried_at"=>1404121570.2233822}
2014-06-30T09:46:10Z 11971 TID-9oues WARN: execution expired

rails 4.0.5
postmark-rails (> 0.8.0)
postmark (1.3.1)
devise (
> 3.2.3)
devise-async (0.9.0)

Cannot start server after requiring gem

After adding "gem 'postmark-rails'" to my Gemfile, I get the following error when starting the development server:
/home/donnie/.rvm/gems/ruby-1.8.7-p330/gems/actionpack-3.0.4/lib/abstract_controller/base.rb:114:in `process': The action 'method' could not be found for ActionMailer::Base (AbstractController::ActionNotFound)
I have tried switching from ruby 1.8.7 to 1.9.2 and explicitly requiring the postmark gem, to no avail. Any ideas?

Email is sent but does not receive postmark servers

Hi guys,

i integrated postmark into my rails app like discribed in the readme. In my server log I get this:

Sent mail to [email protected] (2497ms)
Date: Sun, 07 Aug 2011 14:09:44 +0200
From: [email protected]
To: [email protected]
Message-ID: [email protected]
Subject: User Activation
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
tag: activation

but when I look into the postmark webinterface, no message was delivered. Looks like postmark isn't used correctly. What I am doing wrong?

greets,

Matthias

HTTP Header not set

I have followed the instructions for using this gem as a drop-in for ActionMailer, but am receiving the following error when attempting to trigger an email (Devise password reset).

Postmark::InvalidMessageError (No Account or Server API tokens were supplied in the HTTP headers. Please add a header for either X-Postmark-Server-Token or X-Postmark-Account-Token.)

I would assume the following line would cause the API key to be passed through as the HTTP header:
config.action_mailer.postmark_settings = { :api_token => Rails.application.secrets.postmark_api_token }

But that does not appear to be the case.

I'm on Rails 5.0.4 and postmark-rails 0.15.0.

Thank you

Some messages do not have response data in multithreaded environment

We are experiencing an issue where about 20% of email does not have response data after calling the .deliver method. The messages are being sent fine, but we are unable to consistently get the message ID due to this issue.

We are using the default :ActiveSupport JSON adapter, and here is our config:

config.action_mailer.postmark_settings = {api_key: CONFIG[:postmark_api_key], 
return_response: true, track_opens: true}

Our environment is as follows:

  • Rails 3.2.22.2
  • JRuby 9.1.2.0
  • Postmark 1.7.1
  • Postmark-rails 0.12.0

I am in process of deploying a monkey-patched API client with additional logging to hopefully determine what is going on. Any additional advice would be appreciated.

Rails 3.1.1 Incompatible

Hey guys,

The gem needs to be updated to support Rails 3.1.1. Bundler throws the following error:

rails (~> 3.1.1) depends on
actionmailer (= 3.1.1)

postmark-rails (= 0.4.1) depends on
  actionmailer (3.1.0)

I don't know if it's safe just to adjust the dependencies in the gem or not but wanted to let you know!

No "postmark_settings=" method on ActionMailer::Base

Using Rails 3.2.1, postmark 0.9.10, and postmark-rails 0.4.1, I get the following error:

NoMethodError: undefined method `postmark_settings=' for ActionMailer::Base:Class

This line in application.rb is the one that causes it:

config.action_mailer.postmark_settings = { :api_key => "MY-KEY-HERE" }

Update configuration in README

I'm using Rails 3.2 and postmark-rails 0.4.2.

The configuration in your README is:

config.action_mailer.delivery_method = :postmark
config.action_mailer.postmark_settings = { :api_token => "your-api-token" }

But I had to use:

config.action_mailer.delivery_method = :postmark
ActionMailer::Base.postmark_settings = { :api_key => "your-api-token" }

Rails 4.0.0.rc1 - Sender signature not defined for From address

When generating a new application, and trying to send out the email from Devise I am getting the following error:

Postmark::InvalidMessageError (Sender signature not defined for From address.):
postmark (1.0.0) lib/postmark/http_client.rb:68:in handle_response' postmark (1.0.0) lib/postmark/http_client.rb:86:inblock in do_request'
postmark (1.0.0) lib/postmark/http_client.rb:85:in synchronize' postmark (1.0.0) lib/postmark/http_client.rb:85:indo_request'
postmark (1.0.0) lib/postmark/http_client.rb:27:in post' postmark (1.0.0) lib/postmark/api_client.rb:37:inblock (2 levels) in deliver_message'
postmark (1.0.0) lib/postmark/api_client.rb:134:in take_response_of' postmark (1.0.0) lib/postmark/api_client.rb:37:inblock in deliver_message'
postmark (1.0.0) lib/postmark/api_client.rb:104:in with_retries' postmark (1.0.0) lib/postmark/api_client.rb:36:indeliver_message'
postmark (1.0.0) lib/postmark/handlers/mail.rb:14:in deliver!' mail (2.5.4) lib/mail/message.rb:2129:indo_delivery'
mail (2.5.4) lib/mail/message.rb:232:in `block in deliver'

Rails, or ActionMailer?

Is there anything Rails-specific about this gem, or is it for ActionMailer? I'm successfully using it in a non-Rails project that uses ActionMailer. Might be worth mentioning this in your docs :)

John

How to we catch and handle Postmark::InvalidMessageError

I noticed in my error log today a number of these:

Postmark::InvalidMessageError
You tried to send to a recipient that has been marked as inactive. Found inactive addresses:

Since we don't do anything special except use Rails 2.3's normal ActiveMailer for sending mail, how do we capture and act on these errors that the Gem is returning?

up to date?

Is postmark-rails still the recommended way to integrate postmark into rails apps? Or should we just use postmark-gem. I just noticed that the codebase hasn't been touched in forever.

Inline Attachments ?

Hi,

I haven't been able to send inline images with :postmark_attachments

Is there a way to do it ?

Thanks for your help.

undefined method `encoding' for #<Hash:0x000001045ee598>

I'm getting this error when trying to send an attachent like so:

mail from: "...",
  to: '...',
  subject: "...",
  postmark_attachments: {
    'Name' => "test.pdf",
    'Content' => Base64.encode64('<pdf content>'),
    'ContentType' => "application/pdf"
  }

using postmark-rails 0.4.1, postmark 0.9.6, ActionMailer 3.0.6 and mail 2.2.15. it works with older mail versions (2.2.10).

Document using the gem with Devise

The Devise gem is the de-facto standard for implementing authentication in Rails. It also assumes the responsibility of sending some common types of transactional emails, such as sign up confirmations, password reset links, welcome emails, and others.

The postmark-rails gem is known to work seamlessly with Devise, as it relies on basic ActionMailer facilities. That said, some users reported confusion regarding how certain Postmark features (e.g., templates) fit with Devise. Thus, it might be worth providing an official guide for getting started with Devise on Postmark. Such guide would cover the following:

  • Initial configuration
  • Development VS production
  • Customization (Rails templates VS Postmark templates)

uninitialized constant Postmark::AttachmentsFixForMail (NameError)

Getting:
uninitialized constant Postmark::AttachmentsFixForMail (NameError)
On startup after upgrading to 0.4.1

Stack:
/Users/pragone/.rvm/gems/ruby-1.9.3-p327@aidin/gems/postmark-rails-0.4.1/lib/postmark-rails.rb:22:in install_in_rails_3' /Users/pragone/.rvm/gems/ruby-1.9.3-p327@aidin/gems/postmark-rails-0.4.1/lib/postmark-rails.rb:10:inauto_detect_and_install'
/Users/pragone/.rvm/gems/ruby-1.9.3-p327@aidin/gems/postmark-rails-0.4.1/lib/postmark-rails.rb:27:in <top (required)>' /Users/pragone/.rvm/gems/ruby-1.9.3-p327@aidin/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:inrequire'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.