2009-11-25 69 views
0

我想從我的紅寶石應用程序生成電子郵件,所以我使用了Action郵件類。電子郵件不會出去

我配置了電子郵件設置上的environment.rb我的配置如下

ActionMailer::Base.raise_delivery_errors = false 
ActionMailer::Base.delivery_method = :smtp 
ActionMailer::Base.smtp_settings = { 
    :address => "mail.authsmtp.com", 
    :port => 2525, 
    :user_name => "*******", 
    :password => "*******", 
    :authentication => :login 
} 

我的郵件模式是TestMailer,所以我決定來檢查郵件操作上TestMailer.rb這樣定義方法。

def test_mail(to) { 
    subject "My first email!" 
    recipients "#{to}" 
    from 'test' 
    charset "utf-8" 
    content_type 'text/html' 
    body "Testing one two three..." 
} 

我打開ruby Script/console並調用TestMailer.deliver_test_mail("[email protected]")的test_mail方法。

它不生成電子郵件。在應用程序服務器日誌中,它生成電子郵件模板。
我不知道這裏的probs是什麼。

+0

什麼'ActionMailer :: Base.perform_deliveries'在控制檯中給你?您的日誌是否說明電子郵件已發送? – Ben 2009-11-25 08:09:09

回答

1

您應該檢查config/environments/development.rb | test.rb | production.rb (取決於你如何啓動您控制檯)

,並驗證,如果它不覆蓋SMTP設置,您必須在environment.rb中

0

如果你跑了這一點:

ruby script/console 

。 ..然後你處於開發模式,這可能有「perform_deliveries = false」或其他設置delivery_method

而是,在生產模式下運行控制檯:

ruby script/console production 

...或將config/environments/development.rb更改爲「perform_deliveries = true」。

注意從environment.rb中這樣評論:

# Settings in config/environments/* take precedence over those specified here. 

所以,如果事情是在這兩個地方定義的,它會受到環境的特定設置覆蓋!