2010-11-28 29 views
0

Rails 2.3.5郵件實際上並沒有通過我的日誌說它是

這是在我的本地。

我有一個簡單的模型/視圖/控制器

#contact.rb 

def deliver_contact 
    ContactMailer.deliver_contact(self) 
end 

#contacts_controller 

def create 
    @contact = Contact.new(params[:contact]) 

    respond_to do |wants| 
    if @contact.save 
     @contact.deliver_contact 
     #flash[:notice] = 'Contact was successfully created.' 
     wants.html { redirect_to('/thanks') } 
    else 
     wants.html { render :action => "new" } 
    end 
    end 

日誌說,它走出去..我可以在我的控制檯做到這一點,它說,它走出去。但是我的收件箱中沒有收到任何內容。我錯過了什麼?

更新

這裏是我的development.rb

ActionMailer::Base.delivery_method = :smtp 
ActionMailer::Base.smtp_settings = { 
    :address => "smtp.gmail.com", 
    :port => '25', 
    :domain => "website.com", 
    :authentication => :login, 
    :user_name => "[email protected]", 
    :password => "aged-cheese" 
} 

的創建日誌

Processing ContactsController#create (for 127.0.0.1 at 2010-11-28 16:12:49) [POST] 
    Parameters: {"commit"=>"PUNCH IT, CHEWY!", "action"=>"create", "authenticity_token"=>"3zayXGIOWeNLwb+jhx5cIxWgHqEJdv6iwj6I=", "contact"=>{"name"=>"bob marley", "message"=>"asdfasdf", "state_id"=>"Regarding an existing order", "email"=>"[email protected]"}, "controller"=>"contacts"} 
Cache miss: Spree::Config ({}) 
    Preference Load (0.3ms) SELECT * FROM "preferences" WHERE ("preferences".owner_id = 1 AND "preferences".owner_type = 'Configuration') 
    Configuration Load (0.1ms) SELECT * FROM "configurations" WHERE ("configurations"."id" = 1) 
    CACHE (0.0ms) SELECT * FROM "configurations" WHERE ("configurations"."id" = 1) 
Cache write (will save 2.65ms): Spree::Config 
    Contact Create (0.8ms) INSERT INTO "contacts" ("name", "city", "zip", "created_at", "optin", "updated_at", "state_id", "message", "email") VALUES('bob marley', NULL, NULL, '2010-11-28 21:12:49', NULL, '2010-11-28 21:12:49', 'Regarding an existing order', 'asdfasdf', '[email protected]') 
Sent mail to [email protected] 

Date: Sun, 28 Nov 2010 16:12:50 -0500 
From: [email protected] 
To: [email protected] 
Subject: HOLY [email protected] you got mail! 
Mime-Version: 1.0 
Content-Type: text/html; charset=utf-8 

<strong>You have just received a dank crispy email.</strong> 
<br /> 
<p> 
    Here are the details of the message: 
</p> 
<p> 
    <strong>Name:</strong> 
    bob marley 
</p> 
<p> 
    <strong>Email:</strong> 
    [email protected] 
</p> 

<p> 
    <strong>Subject:</strong> 
    Regarding an existing order 
</p> 

<p> 
    <strong>Message:</strong> 
    <br /> 
    asdfasdf 
</p> 
Redirected to http://localhost:3000/thanks 
Completed in 893ms (DB: 5) | 302 Found [http://localhost/contacts] 

更新:

嘗試使用gmail tls插件,但沒有奏效。嘗試將settings.rb的設置移至development.rb。

我正在使用spree,但是如果我在環境中放置了某些東西,或者在/ config中放置了development.rb,它將覆蓋Spree的默認值。另外,我可以在Spree的管理員中創建郵件服務器,並且使用正確的規格,它仍然沒有預算。

+0

是否郵件發送該機器上工作的呢? – 2010-11-28 19:58:24

+0

你檢查了你的SPAM文件夾嗎? – bitxwise 2010-11-28 20:04:13

+0

@馬丁,是的,它在我的其他應用程序。 --- @bitxwise,是的,沒有出現。 – Trip 2010-11-28 21:24:50

回答

0

我發現兩個項目,爲我解決這件作品。

  1. 我正在使用Spree,所以我的意思是我必須在內部配置郵件設置。在我意識到我已經與@ lbz的請求一起在Gmail發送中安裝TLS插件之前。事實證明,這與設置無關,所以當我卸載它時,它就起作用了。

  2. 爲了讓郵件被測試服務器上發送,還必須註釋此行:

    # config.action_mailer.delivery_method = :test

6

如果您在開發模式下運行您的應用程序,您的電子郵件將不會被髮送,但會被記錄下來。要真正在發送電子郵件發展到什麼樣的模式改變config/environment.rb

Rails::Initializer.run do |config| 
    ... 
    config.action_mailer.delivery_method = :sendmail # add this line 
end 
1

config\environments\development.rb你還有以下幾行:

# Don't care if the mailer can't send 
config.action_mailer.raise_delivery_errors = false 

如果是這樣,評論者,並添加以下行 使發展的交付:

# To test if we can actually send mails! 
config.action_mailer.raise_delivery_errors = true # for test 
config.action_mailer.perform_deliveries = true 
相關問題