[英]Rails 4 action_mailer host
對於Rails 4,我在以下位置使用config.action_mailer.asset_host = "http://localhost:3000"
config > environments > development.rb
將資產加載到我的郵件中。
是否有比硬編碼網址更好的價值? 我想應該有一個,因為我不會在production.rb
使用此值。 在rails config中查找當前主機URL的代碼是什么?
如果部署到已知主機,則可以將其直接放入production.rb
但是,如果您確實需要從url讀取它,則可以將其簽出
http://api.rubyonrails.org/classes/ActionDispatch/Request.html#method-i-original_url
如果您使用的是SendGrid ,則在config/environment.rb
文件中,指定ActionMailer設置以指向SendGrid的服務器。
ActionMailer::Base.smtp_settings = {
:user_name => 'your_sendgrid_username',
:password => 'your_sendgrid_password',
:domain => 'yourdomain.com',
:address => 'smtp.sendgrid.net',
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.