Forum: Ruby on Rails action mailer settings and dkim signing

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4d9c0d70c627c7d1f64fa7301b6d0e6e?d=identicon&s=25 Stephen Burke (Guest)
on 2015-02-15 09:08
(Received via mailing list)
I am trying to figure out why this block of code in my
environments/production.rb file is causing the dkim signing to break.  I
have email being sent from a rake task with my UserMailer class.  It is
derived from Devise::Mailer.  If I have the action_mailer configuration
block within the "config.after_initialize" the dkim signature does not
go
through.  If I don't have that line "after_initialize" the signature
goes
through.  Can someone shed some light on this for me?

Here's the code for my UserMailer class and the production.rb file.

user_mailer.rb

require "#{Rails.root}/app/helpers/user_helper"
include UserHelper

class UserMailer < Devise::Mailer
  helper :application # gives access to all helpers defined within
`application_helper`.
  include Devise::Controllers::UrlHelpers # Optional. eg.
`confirmation_url`
  default from: "Save The Sparkles <contact@savethesparkles.com>",
  reply_to: "contact@savethesparkles.com"
  ...
end


environments/production.rb

config.action_mailer.asset_host     = 'http://savethesparkles.com'

config.action_mailer.default_url_options = { host: 'savethesparkles.com'
}
config.after_initialize do
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address:              'email-smtp.us-east-1.amazonaws.com',
    port:                 587,
    domain:               'savethesparkles.com',
    user_name:            ENV['AWS_SES_USER'],
    password:             ENV['AWS_SES_PASS'],
    authentication:       :login,
    enable_starttls_auto: true
  }
end
6883e5ef03484d4fcef507d7b4f1d243?d=identicon&s=25 Matt Jones (Guest)
on 2015-02-19 03:20
(Received via mailing list)
On Saturday, 14 February 2015 21:17:21 UTC-5, Stephen Burke wrote:
>
>   default from: "Save The Sparkles <con...@savethesparkles.com
> config.action_mailer.default_url_options = { host: 'savethesparkles.com' }
>     authentication:       :login,
>     enable_starttls_auto: true
>   }
> end
>
>
The documentation for Rails::Railtie::Configuration describes
after_initialize as the "last configurable block to run, called after
frameworks initialize". ActionMailer's own initialization routine copies
the values from config.action_mailer *before* the code above sets them.
So
the behavior you've described makes sense.

A better question is, why is having after_initialize here important?
What's
the intent?

--Matt Jones
This topic is locked and can not be replied to.