0

I cannot get postmark to handle registration and forgot password emails:

user_mailer.rb

class UserMailer < ActionMailer::Base
  include Devise::Mailers::Helpers

  default from: "donotreply@barnpix.com"

  def confirmation_instructions(record)
    devise_mail(record, :confirmation_instructions)
  end

  def reset_password_instructions(record)
    devise_mail(record, :reset_password_instructions)
  end

  def unlock_instructions(record)
    devise_mail(record, :unlock_instructions)
  end

  # you can then put any of your own methods here
end

application.rb

config.action_mailer.delivery_method   = :postmark
    config.action_mailer.postmark_settings = { :api_key => ENV['9302106a-63xxxx-xxx-xx-'] }

user.rb

devise :database_authenticatable, :registerable, :recoverable,
         :rememberable, :trackable, :validatable

devise.rb

config.mailer = "UserMailer" # UserMailer is my mailer class

I cannot get this to work at all. Any hints as to what I might be doing wrong or what I might be missing to get this to work ?

westman2222
  • 663
  • 1
  • 12
  • 30
  • Probably not a problem for you anymore, but the [docs](https://postmarkapp.com/loves/rails) point to using `api_token`, not `api_key`. (They also suggest hard-coding the token though, which is probably not a great idea.) – mwfearnley Aug 16 '19 at 11:35

1 Answers1

1

I think your problem is caused by this line:

config.action_mailer.postmark_settings = { :api_key => ENV['9302106a-63xxxx-xxx-xx-'] }

ENV is a hash of all environment variables. You should use names to access the values. I guess you’re using Postmark on Heroku, so it will be ENV['POSTMARK_API_KEY'] in that case.

temochka
  • 436
  • 3
  • 5