ryanb / letter_opener

Preview mail in the browser instead of sending.
MIT License
3.73k stars 238 forks source link

Using with Mandrill Mailer #119

Closed sars closed 8 years ago

sars commented 8 years ago

here is integration:

if Rails.const_defined?("MandrillMailer") && Rails.application.config.action_mailer[:delivery_method] == :letter_opener
  MandrillMailer::TemplateMailer.class_eval do
    define_method :deliver do
      opts = {
          from: message['from_email'],
          to: message['to'].map{|m| m['email']}.join(', '),
          subject: message['subject'],
          body: JSON.pretty_generate(message)
      }
      ActionMailer::Base.mail(opts).deliver
    end
  end
end

in initializers

if you want, i can make PR with integration

nashby commented 8 years ago

Hey, thank you for your help but I think it can live as separate gem since I don't think everyone need this feature.