Slowboy Slowboy - 21 days ago 4x
Ruby Question

Using { host: 'localhost', port: 3000 } in ActionMailer in Production.rb for deployment to VPS?

This is the first time I'm working with actionmailer in production.

Earlier I deployed an App to a VPS server. I haven't assigned a domain to it yet so it is only an IP address.

I configured the action mailer settings, but I'm curious about this line:

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
can I use the Ip address of the server instead of
{ host: 'localhost', port: 3000 }
or does the server act as a localhost after the app is deployed with this setting?

Here is the setup code in the

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: ENV["SMTP_ADDRESS"],
user_name: ENV["SMTP_USER"],
password: ENV["SMTP_PASSWORD"],
domain: "",
port: 587,
authentication: :login,
enable_starttls_auto: true

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

Once you have configured this and you use these settings to send the mail via gmail server. The default url will be used as the domain name of website/application like say for forgot password to users.


You should be changing this to the domain name or the ip where the application code is hosted. localhost is used only for development setups.