I would like to send a small number of letters from my application through Gmail. Now the SMTP settings will be determined at runtime (i.e. from db), can this be done?
--- change ---
I can set the smtp parameters of an ActionMailer subclass (named Notifier) ββin one of the class methods. That way, I can set a username and password for sending emails dynamically. The only thing you need to set ALL smtp_settings. Is it possible to set only the username and password in the class method?
This is the code I'm using right now, it sends:
class Notifier < ActionMailer::Base def call(user) Notifier.smtp_settings = { :enable_starttls_auto => true, :address => "smtp.gmail.com", :port => "587", :domain => "mydomain.com", :authentication => :plain, :user_name => " fabian@mydomain.com ", :password => "password" } recipients user.email subject "Test test" body "Test" end end
I would just like to specify the username and pw here.
Fabian
source share