我死路一条!我正在尝试制作一个应用程序来接收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&gt;环境&gt; 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'
}
在视图&gt; recivemails&gt; show
中 <%=@recivemail.sendmail(@recivemail.from,@recivemail.subject,@recivemail.content)%>
答案 0 :(得分:3)
@recivemail.send(@recivemail.from,@recivemail.subject,@recivemail.content)
Ruby中的send
方法意味着“向此对象发送消息”(as-in调用由send
的第一个参数命名的方法)。你在这里做的是尝试调用一个以@recivemail.from
的值命名的方法到对象@recivemail
。
http://ruby-doc.org/core-1.9.3/Object.html#method-i-send
在您的代码中,该方法无论如何都被命名为sendmail
而不是send
。
(我也不会把它放到一个视图中,但这似乎是你现在最麻烦的。)
关于接收电子邮件的原始问题,请启动with this article。这是几年前写的,但应该给你一些想法。