这是我第一次在生产中使用actionmailer。
早些时候,我将应用程序部署到VPS服务器上。我还没有给它分配一个域,所以它只是一个IP地址。
我配置了操作邮件程序设置,但我对这一行很好奇:config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
可以使用服务器的Ip地址而不是{ host: 'localhost', port: 3000 }
吗?或者在应用程序部署到此设置之后,服务器是否充当本地主机?
以下是production.rb
中的设置代码
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: "gmail.com",
port: 587,
authentication: :login,
enable_starttls_auto: true
}
发布于 2016-10-04 08:43:06
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
一旦您配置好它,并使用这些设置通过gmail服务器发送邮件。默认的url将用作网站/应用程序的域名,比如用户忘记密码。
http://localhost:3000/forgot_password?email="fd@ds.com"
您应该将其更改为承载应用程序代码的域名或ip。localhost仅用于开发设置。
https://stackoverflow.com/questions/39857364
复制相似问题