2014-09-29 112 views
0

因此,我的項目之一有一個SMTP服務器已配置爲使用沒有任何形式的身份驗證。這是我在config/environments/production.rb上的SMTP設置。Rails ActionMailer發送電子郵件沒有身份驗證

config.action_mailer.asset_host = 'http://example.com' 
config.action_mailer.default_url_options = { host: 'example.com' } 
config.action_mailer.delivery_method = :smtp 
config.action_mailer.raise_delivery_errors = true 
config.action_mailer.smtp_settings = { 
    address:    'mail.example.com', 
    port:    587, 
    domain:    'info.example.com', 
    user_name:   '[email protected]', 
    password:    '', 
    openssl_verify_mode: 'none', 
    authentication:  nil, 
    tls:     false, 
    enable_starttls_auto: false 
} 

我雖然authentication模式需要被設置爲nil,但是,當我試圖發送電子郵件,它給了我這個錯誤。

2.0.0-p481 :001 > CustomerMailer.test.deliver 
Net::SMTPAuthenticationError: 503 5.5.1 Error: authentication not enabled 

任何解決方案,傢伙?

回答

3

您正在指定驗證詳細信息。 ActionMailer會相應地使用它們。

解決方法:不要。

config.action_mailer.smtp_settings = { 
    address: 'mail.example.com', 
    port: 587, 
    domain: 'info.example.com' 
} 

(該domain參數可以根據自身您的服務器配置是不必要的。)

+0

它給我'引發ArgumentError:SMTP-AUTH請求但缺少祕密phrase'錯誤。 – 2014-09-29 06:53:27

+0

好的。它現在有效。謝謝。 :) – 2014-10-01 12:17:15

相關問題