Flowdock
pop( dest = '' ) public

This method fetches the message. If called with a block, the message is yielded to the block one chunk at a time. If called without a block, the message is returned as a String. The optional dest argument will be prepended to the returned String; this argument is essentially obsolete.

Example without block

POP3.start('pop.example.com', 110,
           'YourAccount, 'YourPassword') do |pop|
  n = 1
  pop.mails.each do |popmail|
    File.open("inbox/#{n}", 'w') do |f|
      f.write popmail.pop              
    end
    popmail.delete
    n += 1
  end
end

Example with block

POP3.start('pop.example.com', 110,
           'YourAccount, 'YourPassword') do |pop|
  n = 1
  pop.mails.each do |popmail|
    File.open("inbox/#{n}", 'w') do |f|
      popmail.pop do |chunk|            ####
        f.write chunk
      end
    end
    n += 1
  end
end

This method raises a POPError if an error occurs.

Show source
Register or log in to add new notes.