0

Rails アプリでオブジェクトを作成してMailいて、メーラー設定を選択する必要があります。

original = UserMailer.new_registration
original.deliver# Does the job

custom = Mail.new(original.to_s)
custom.deliver # Fails: OpenSSL::SSL::SSLError: hostname does not match the server certificate

カスタムMailオブジェクトが Rails の設定を反映していないようです。

4

2 に答える 2

4

コードを見ると、次の方法でメーラーから構成を取得できます。

custom = ::Mail.new(raw_email)
key = Rails.application.config.action_mailer.delivery_method
delivery_method = ActionMailer::Base.delivery_methods.fetch(key)
delivery_settings = ActionMailer::Base.send("#{key}_settings")
custom.delivery_method(delivery_method, delivery_settings)
custom.deliver
于 2012-11-11T22:17:49.710 に答える