2012-06-25 33 views
0

我在死衚衕!我正在嘗試製作一個應用程序來接收hotmail上的電子郵件!我在方法創建的方法和我收到一個錯誤,沒有電子郵件接收..如何接收來自Rails應用程序的紅寶石電子郵件

class Recivemail < ActiveRecord::Base 
    attr_accessible :content, :from, :subject 

def sendmail(content,from,subject) 
    subject = 'subject' 
    recipients = "[email protected]" 
    from = 'from' 
    sent_on = Time.now 
    end 
end 

在配置> enviroments> development.rb

config.action_mailer.delivery_method = :smtp 
    config.action_mailer.smtp_settings ={ 
    :enable_starttls_auto => true, 
    :address => 'smtp.hotmail.com', 
    :port => 587, 
    :authentication => :plain, 
    :domain => 'localhost:3000', 
    :user_name => '[email protected]', 
    :password => 'mypass' 

    } 
的意見> recivemails

>顯示

<%[email protected](@recivemail.from,@recivemail.subject,@recivemail.content)%>

一切似乎工作正確除了我沒有收到任何電子郵件 任何想法?

回答

3

@recivemail.send(@recivemail.from,@recivemail.subject,@recivemail.content)

Ruby中send方法是指「將消息發送到該對象」(如式呼叫由第一參數指定到send的方法)。你在這裏做的是試圖調用一個名爲@recivemail.from的方法到對象@recivemail

http://ruby-doc.org/core-1.9.3/Object.html#method-i-send

在你的代碼,該方法被命名爲sendmailsend反正。

(我不會把這個變成一個視圖兩種,但似乎是最煩惱的現在。)

至於你提到接收標準郵件原來的問題,開始with this article。這是幾年前寫的,但應該給你一些想法。

+0

大聲笑,所以noobish!我正在努力學習ror! thx這是正確的:)) 但仍然沒有電子郵件接收.. – marios

+0

令人困惑的是,你有一個名爲'ReceiveMail'的類中稱爲'sendmail'的方法。我不完全確定你要完成什麼,因爲看起來你只是在探索Rails,所以我想幫助解決跳出我的問題。 – jdl

+0

我想製作一個應用程序,用戶可以給我發電子郵件..我必須下載actionmailer包裝?我不知道爲什麼現在不工作,現在我修復了這個問題... – marios

相關問題