2016-10-04 43 views
0

這是我第一次與生產中的actionmailer合作。在Production.rb的ActionMailer中使用{host:'localhost',port:3000}部署到VPS?

此前我部署了一個應用程序到VPS服務器。我還沒有分配域名,所以它只是一個IP地址。

我配置的操作郵件設置,但我很好奇這行: config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }我可以使用服務器而不是{ host: 'localhost', port: 3000 }的IP地址或做的服務器作爲本地主機的應用程序部署在此設置後?

這裏是在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 
} 

回答

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

一旦你已經完成了這個設置代碼,並使用這些設置通過Gmail的服務器來發送郵件。默認的網址將被用作網站/應用程序的域名,比如說爲用戶忘記密碼。

http://localhost:3000/forgot_password?email="[email protected]" 

您應該將其更改爲託管應用程序代碼的域名或IP。本地主機僅用於開發設置。

+0

好的,謝謝你。這正是我在找的東西。那麼我會把這個IP地址放在這個'{host:'123.123.123.123',port:???? }'那個港口呢?它可以保持不變嗎? – Slowboy

+1

爲什麼會有一個生產設置的端口,它應該默認爲80,如果它暴露給其他用戶,那麼當然會使用端口 – Bijendra

+0

,當然我很傻:)然後我把主機設置爲'{host:'123.123.123.123 '}'? – Slowboy

相關問題