[英]how to receive emails from a ruby on rails app
我死定了! 我正在嘗試制作一個應用程序來接收Hotmail上的電子郵件! 我創建了一個方法,但出現錯誤,沒有收到電子郵件。
用我的方法:
class Recivemail < ActiveRecord::Base
attr_accessible :content, :from, :subject
def sendmail(content,from,subject)
subject = 'subject'
recipients = "linkinpark_8884@hotmail.com"
from = 'from'
sent_on = Time.now
end
end
在config> 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 => 'linkinpark_8884@hotmail.com',
:password => 'mypass'
}
在視圖>接收郵件>顯示
<%=@recivemail.sendmail(@recivemail.from,@recivemail.subject,@recivemail.content)%>
一切似乎工作正常,除了我沒有收到任何電子郵件任何想法?
@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
在您的代碼中,該方法名為sendmail
仍然不send
。
(我也不會考慮這一點,但這似乎是您目前最少的麻煩。)
至於您最初關於接收電子郵件的一般問題,請從本文開始。 它是幾年前寫的,但應該給您一些想法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.