Configurar o ActionMailer para enviar e-mail por caixas diferentes (servidores ou portas).
Depois de pesquisar uma boa parte da manhã sobre o como fazer o problema, chegamos numa solução que ficou simples.
Colocamos este método
def register_delivery_method(method, settings, options = {})
ActionMailer::Base.add_delivery_method method, Mail::SMTP
ActionMailer::Base.send("#{method}_settings=", settings.merge(options))
end
Interceptor
#encoding: utf-8
class DistributionMailInterceptor
def self.find_method(mail_to)
match = mail_to.match(/@([^.]+)/)
return :others unless match
method = match[1].to_sym
if ActionMailer::Base.delivery_methods.include?(method)
method
else
:others
end
end
def self.delivering_email(mail)
method = find_method(mail.to)
mail.delivery_method(ActionMailer::Base.delivery_methods[method],
ActionMailer::Base.send("#{method}_settings"))
end
end