1

我正在嘗試製作例外通知程序。我安裝了寶石,並把這個代碼production.rb:例外通知

config.action_mailer.delivery_method = :sendmail 
    # Defaults to: 
    config.action_mailer.sendmail_settings = { 
    :location => '/usr/sbin/sendmail', 
    :arguments => '-i -t' 
    } 

    config.action_mailer.perform_deliveries = true 

    config.action_mailer.raise_delivery_errors = true 

    config.middleware.use ExceptionNotifier, 
     :email_prefix => "Error 500", 
     :sender_address => %{"Notifier" <[email protected]>}, 
     :exception_recipients => %w{[email protected]} 

這不會引發任何錯誤,但它並沒有任何發送郵件。請幫助。

+0

您的應用程序是否在生產模式下運行?你的MTA的日誌裏有什麼(postfix,exim4,...)?您是否嘗試過在終端中發送異常通知以查看問題出在哪裏? – pduersteler 2013-05-08 16:57:55

+0

是的,它在生產模式下運行。儘管我找到了解決方案。謝謝 ! – 2013-05-08 17:27:52

回答

1

我把它換成:

config.action_mailer.delivery_method = :sendmail 
    # Defaults to: 
    config.action_mailer.sendmail_settings = { 
    :location => '/usr/sbin/sendmail', 
    :arguments => '-i -t' 
    } 

有了:

config.action_mailer.delivery_method = :smtp 

config.action_mailer.smtp_settings = { 
    :address => "smtp.gmail.com", 
    :port => 587, 
    :domain => "google.com", 
    :user_name => "[email protected]", 
    :password => "password", 
    :authentication => "plain", 
    :enable_starttls_auto => true } 

它工作得很好:d!