views:

296

answers:

1

I saw this post but mine is slightly different:

http://stackoverflow.com/questions/1559879/rails-actionmailer-with-multiple-smtp-servers

I am allowing the users to send mail using their own SMTP credentials so it actually does come from them.

But they will be sent from the Rails app, so that means for each user I need to send their emails using their own SMTP server.

How can I do that?

+1  A: 

Just set the ActionMailer::Base configuration values before each send action.

smtp_config = user.smtp_configuration

ActionMailer::Base.username = smtp_config.username
ActionMailer::Base.password = smtp_config.password
ActionMailer::Base.server = ..
ActionMailer::Base.port = ..
ActionMailer::Base.authentication = ..
simianarmy
How do I do that? ActionMailer configs are in the config file...Creating a local variable called smtp_config and then pass the respective methods?
Angela
SO just lost my previous answer, so trying again with a shorter note.You are just setting ActionMailer class variables in those calls. Typically they are defined in the configs, but you can change them anytime you want. In your case you want to set them before every ActionMailer child class's deliver_XXX method that you need to call.
simianarmy