![](/img/trans.png)
[英]Rails / Devise / Mailer: Throwing 'config.action_mailer.default_url_options' error on attempted registration
[英]rails config mailer default url options not taking effect (development environment)
我正在調整出現在創建的郵件中的 url,
<%= controller_url %>
但是當我使用以下命令更改默認值時
config.action_mailer.default_url_options = { :host => "example.com", :protocol => 'https', :subdomain => "www"}
網址保持不變
這不起作用的一些可能原因是什么? 我在我的項目文件夾中仔細查看了可能定義主機或子域的位置,但一無所獲。
編輯:似乎我需要在進行更改后重新啟動我的服務器。
我不知道您如何嘗試,但我可以展示我的文件以與您的文件進行比較。
所以我的開發文件是/config/environments/development.rb
config.consider_all_requests_local = true
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
我的生產文件是/config/environments/production.rb
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => "https://example.com" } #=> Or https://www.example.com
config.action_mailer.perform_deliveries = true
ActionMailer::Base.smtp_settings = {
:user_name => ENV['USERNAME'],
:password => ENV['PASSWORD'],
:domain => 'example.com',
:address => 'smtp.example.net',
:port => 321,
:authentication => :plain,
:enable_starttls_auto => true
}
config.action_mailer.delivery_method = :smtp
它運行良好。
記住這些:
您可以在發送郵件時檢查日志正在發生的事情和生產運行遵循此命令rails server -e production
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.