2011-06-10 76 views
1

當我點擊設計發送的確認電子郵件中的鏈接時,它似乎轉到我的應用程序無法識別的路徑。設計電子郵件確認在Heroku上不起作用

的URL看起來是這樣的:

http://glowing-flower-855.heroku.com/users/confirmation?confirmation_token=lIUuOINyxfTW3TBPPI

這看起來是正確的,但似乎去我500.html文件。

它有事情做與此代碼在我的用戶模型,覆蓋設計的confirm!方法:

def confirm! 
    UserMailer.welcome_message(self).deliver 
    super 
end 

根據我的記錄,這是錯誤:

2011-06-10T03:48:11+00:00 app[web.1]: ArgumentError (A sender (Return-Path, Sender or From) required to send a message): 
2011-06-10T03:48:11+00:00 app[web.1]: app/models/user.rb:52:in `confirm!' 

指向這個行:UserMailer.welcome_message(self).deliver

這是我的用戶郵件類:

class UserMailer < ActionMailer::Base 
    def welcome_message(user) 
    @user = user 
    mail(:to => user.email, :subject => "Welcome to DreamStill") 
    end 
end 
+0

是什麼在你的日誌,有關錯誤的? – sevenseacat 2011-06-10 03:56:04

+0

2011-06-10T03:48:11 + 00:00 app [web.1]:ArgumentError(需要發送郵件的發件人(返回路徑,發件人或發件人): 2011-06-10T03:48: 11 + 00:00 app [web.1]:app/models/user.rb:52:在'confirm!'中 – 2011-06-10 04:00:00

+0

它指向這行'UserMailer.welcome_message(self).deliver' – 2011-06-10 04:00:26

回答

7

你缺少了「從:」值,這對SMTP處理一絕:

class UserMailer < ActionMailer::Base 
    # Option 1 
    #default_from "[email protected]" 

    def welcome_message(user) 
    @user = user 
    mail(
     # Option 2 
     :from => "[email protected]", 
     :to => user.email, 
     :subject => "Welcome to DreamStill" 
    ) 
    end 
end