Dynamically changing ActionMailer::Base.delivery_method

Hi all,

I need some of my emails to go out using “smtp” and some others using
“sendmail” . Is there a clean way to switch between these two deliver
methods depending upon the mailer method?

Thanks!

maybe with a rake task for the send mail one, running with deamon but it
will have to load your app and change the config, i think it will get
ugly.

On Sep 9, 6:47 am, Ram [email protected] wrote:

Hi all,

I need some of my emails to go out using “smtp” and some others using
“sendmail” . Is there a clean way to switch between these two deliver
methods depending upon the mailer method?

I think (but do test this!) that you could do something like

class SmtpMailer < AM::Base
self.delivery_method = :smtp
end

class SendmailMailer < AM::Base
self.delivery_method = :sendmail
end

and then derive mailers from those two classes as appropriate. If you
have identical mail that needs to be delivered via either of those two
mechanisms then it might be a bit more complicated.

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs