dynamically changing ActionMailer::Base.delivery_method

13 views
Skip to first unread message

Ram

unread,
Sep 9, 2010, 1:47:25 AM9/9/10
to Ruby on Rails: Talk
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!

radhames brito

unread,
Sep 9, 2010, 7:18:14 AM9/9/10
to rubyonra...@googlegroups.com
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.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


Frederick Cheung

unread,
Sep 9, 2010, 7:22:03 AM9/9/10
to Ruby on Rails: Talk
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
Reply all
Reply to author
Forward
0 new messages