IMAP: recieve email at runtime

Discussion in 'Ruby' started by Eilie, Jun 3, 2012.

  1. Eilie

    Eilie Guest

    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.
     
    Eilie, Jun 3, 2012
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.