[英]how to receive emails from a ruby on rails app
i am in dead end! 我死定了! i am trying to make an app to receive emails on hotmail! 我正在尝试制作一个应用程序来接收Hotmail上的电子邮件! i created a method and i am getting an error and no email receiving.. 我创建了一个方法,但出现错误,没有收到电子邮件。
in my method: 用我的方法:
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
in config>enviroments>development.rb 在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'
}
in views>recivemails>show 在视图>接收邮件>显示
<%=@recivemail.sendmail(@recivemail.from,@recivemail.subject,@recivemail.content)%>
everything seems to working correct except that i am not getting any email any ideas?? 一切似乎工作正常,除了我没有收到任何电子邮件任何想法?
@recivemail.send(@recivemail.from,@recivemail.subject,@recivemail.content)
The send
method in Ruby means "send a message to this object" (as-in call the method that is named by the first parameter to send
). Ruby中的send
方法的意思是“向该对象发送消息”(按调用方式,由第一个要send
参数命名的方法)。 What you're doing here is trying call a method named by the value of @recivemail.from
to the object @recivemail
. 您在这里正在尝试调用以@recivemail.from
的值命名的方法到对象@recivemail
。
http://ruby-doc.org/core-1.9.3/Object.html#method-i-send http://ruby-doc.org/core-1.9.3/Object.html#method-i-send
In your code, the method is named sendmail
not send
anyway. 在您的代码中,该方法名为sendmail
仍然不send
。
(I would not put this into a view either, but that seems to be the least of your troubles right now.) (我也不会考虑这一点,但这似乎是您目前最少的麻烦。)
As for your original question about receiving emails in general, start with this article . 至于您最初关于接收电子邮件的一般问题,请从本文开始。 It was written several years ago, but should give you some ideas. 它是几年前写的,但应该给您一些想法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.