IMAP: recieve email at runtime

E

Eilie

Hello, how can i recieve email at runtime without reconnecting to IMAP
server?
Here my code:

@imap = Net::IMAP.new(config[:host], config[:port], config[:ssl])
@imap.login(config[:username], config[:password])
@imap.select('inbox')


def get_mail
result = {body: []}
@imap.search(["NOT","SEEN","SUBJECT", "test"]).each do |id|
result[:body] << @imap.fetch(id,
'BODY[TEXT]')[0].attr['BODY[TEXT]']
end
result
end

When i send email to my box and after that i start script with get_mail -
i get my mail.
But when o send email with already running script - i get nothing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top