Skip to content

Instantly share code, notes, and snippets.

@aantix
Created January 13, 2012 23:54
Show Gist options
  • Save aantix/1609431 to your computer and use it in GitHub Desktop.
Save aantix/1609431 to your computer and use it in GitHub Desktop.
Clean Pop3 Account
require 'net/pop'
Net::POP3.start(ARGV.shift, 110,
ARGV.shift, ARGV.shift) do |pop|
if pop.mails.empty?
puts 'No mail.'
else
puts "Deleting #{pop.mails.size} mails."
i = 0
pop.each_mail do |m| # or "pop.mails.each ..."
File.open("inbox/#{i}", 'w') do |f|
f.write m.pop
end
m.delete
i += 1
end
puts "#{pop.mails.size} mails popped."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment