I saw this post but mine is slightly different:
Rails ActionMailer with multiple SMTP servers
I am allowing the users to send mail using their own SMTP crede
For Rails 3.2.x
You can include AbstractController::Callbacks in your mailer class and the do a "after_filter :set_delivery_options" inside the mailer.
The set_delivery_options method would have access to instance variables setup by you in your mailer action and you can access the mail object as "message".
class MyNailer < ActionMailer::Base
include AbstractController::Callbacks
after_filter :set_delivery_options
def nail_it(user)
@user = user
mail :subject => "you nailed it"
end
private
def set_delivery_options
message.delivery_method.settings.merge!(@user.company.smtp_creds)
end
end