2014-07-04 51 views
0

Developerment.rbRails應用程序不發送電子郵件

​​

我看到在日誌文件中「已發送郵件到[email protected]」的消息。 我打這一行

#config.action_mailer.delivery_method = :sendmail 

通過取消註釋本,給了所有這些選項:smtp, :sendmail or :test,但沒有一個似乎工作。

+0

你有沒有配置你的服務器設置發送電子郵件?你可以通過ActionMailer :: Base檢查:http://api.rubyonrails.org/classes/ActionMailer/Base.html – Mavis

+0

@Mavis,我在appln中配置了這一個,ActionMailer :: Base.register_interceptor( SMInterceptor) – user3677652

+0

你想使用smtp或sendmail服務器發送電子郵件嗎? – Mavis

回答

1

如果您使用SMTP發送電子郵件,請確保將服務器配置包含在config/environments/$ RAILS_ENV.rb文件中。這裏是一個例子:

config.action_mailer.delivery_method = :smtp 
config.action_mailer.smtp_settings = { 
    address:    'smtp.gmail.com', 
    port:     587, 
    domain:    'example.com', 
    user_name:   '<username>', 
    password:    '<password>', 
    authentication:  'plain', 
    enable_starttls_auto: true } 
+0

你也可以包含:config.action_mailer.default_url_options = {:host =>'localhost:3000'} - 通過它在上面加上上面的塊。 production.rb然後將反映實際的主機名 – nil

+1

感謝@Mavis,我現在正在收到電子郵件。 – user3677652

+0

@ user3677652當您在生產中遇到錯誤時,添加包含生產名稱的主機名的行,然後您可能會發現我的評論對帖子更有用 – nil

相關問題