njmacinnes-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-23 13:19 UTC
incoming email question
I''m writing a model for receiving incoming email from a remote imap
server.
The problem is, our server isn''t going to be running all of the time,
and so
I''m just going to set it up to check the inbox on each request (there
won''t
be many requests, it''s not a public site). Our rails server is running
Windows. This is what I have so far, pretty much copied from
http://wiki.rubyonrails.org/rails/pages/HowToReceiveEmailsWithActionMailer
def recieve(email)
emailer = Emailer.find_by_address(email.sender)
emailer.messages.create(
:incoming => true,
:subject => email.subject,
:body => email.body,
:time => email
)
end
def send
# not done yet
end
def self.check_mail
imap = Net::IMAP.new(''imap.shef.accept.uk'')
imap.authenticate(''LOGIN'',''username'',''password'')
imap.select(''INBOX'')
imap.search([''ALL'']).each do |message_id|
msg =
imap.fetch(message_id,''RFC822'')[0].attr[''RFC822'']
MailReader.receive(msg)
# imap.store(message_id, "+FLAGS", [:Deleted])
end
end
The problem is that because our server isn''t running all the time, I
want to
get the time the email was sent from the headers. This is very important as
we have strict deadlines relating to replying to emails.
Any help would be much appreciated,
-Nathan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
njmacinnes-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-23 13:29 UTC
Re: incoming email question
oops, the line that say :time => email is in there because I presume it''s email.something, but I don''t know. -N On 23/04/07, njmacinnes-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <njmacinnes-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m writing a model for receiving incoming email from a remote imap > server. The problem is, our server isn''t going to be running all of the > time, and so I''m just going to set it up to check the inbox on each request > (there won''t be many requests, it''s not a public site). Our rails server is > running Windows. This is what I have so far, pretty much copied from > http://wiki.rubyonrails.org/rails/pages/HowToReceiveEmailsWithActionMailer > > def recieve(email) > emailer = Emailer.find_by_address(email.sender) > emailer.messages.create( > :incoming => true, > :subject => email.subject, > :body => email.body, > :time => email > ) > end > > def send > # not done yet > end > > def self.check_mail > imap = Net::IMAP.new('' imap.shef.accept.uk'') > imap.authenticate(''LOGIN'',''username'',''password'') > imap.select(''INBOX'') > imap.search([''ALL'']).each do |message_id| > msg = imap.fetch(message_id,''RFC822'')[0].attr[''RFC822''] > MailReader.receive(msg) > # imap.store(message_id, "+FLAGS", [:Deleted]) > end > end > > > The problem is that because our server isn''t running all the time, I want > to get the time the email was sent from the headers. This is very important > as we have strict deadlines relating to replying to emails. > > > Any help would be much appreciated, > -Nathan >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---