Instead of setting mail smtp parameters in environment specific initializers; I would like the end-user specify it from administration page.
How to achieve it?
Instead of setting mail smtp parameters in environment specific initializers; I would like the end-user specify it from administration page.
How to achieve it?
you can set any kind of ActionMailler config/settings dynamically, just by changing it (which imo is a bad approach. if you offer a saas then youre also capable of sending emails)
def my_controller_action
ActionMailer::Base.server = "mail.gmail.com"
ActionMailer::Base.username = "huan-son"
#...
end
From the Railsdoc
smtp_settings - Allows detailed configuration for :smtp delivery method:
:address - Allows you to use a remote mail server. Just change it from its default “localhost” setting.
:port - On the off chance that your mail server doesn't run on port 25, you can change it.
:domain - If you need to specify a HELO domain, you can do it here.
:user_name - If your mail server requires authentication, set the username in this setting.
:password - If your mail server requires authentication, set the password in this setting.
:authentication - If your mail server requires authentication, you need to specify the authentication type here. This is a symbol and one of :plain (will send the password Base64 encoded), :login (will send the password Base64 encoded) or :cram_md5 (combines a Challenge/Response mechanism to exchange information and a cryptographic Message Digest 5 algorithm to hash important information)
:enable_starttls_auto - Detects if STARTTLS is enabled in your SMTP server and starts to use it. Defaults to true.
:openssl_verify_mode - When using TLS, you can set how OpenSSL checks the certificate. This is really useful if you need to validate a self-signed and/or a wildcard certificate. You can use the name of an OpenSSL verify constant ('none', 'peer', 'client_once', 'fail_if_no_peer_cert') or directly the constant (OpenSSL::SSL::VERIFY_NONE, OpenSSL::SSL::VERIFY_PEER, …).
sendmail_settings - Allows you to override options for the :sendmail delivery method.
:location - The location of the sendmail executable. Defaults to /usr/sbin/sendmail.
:arguments - The command line arguments. Defaults to -i -t with -f sender@address added automatically before the message is sent.