#!/usr/bin/python # Script to download messages from a pop3 account and write them to a new file # mbox2maildir can be used to convert this file into a maildir import getpass, poplib f = open("mail.temp") servername = raw_input("What is the remote server name? ") M = poplib.POP3(servername) M.user(getpass.getuser()) M.pass_(getpass.getpass()) numMessages = len(M.list()[1]) for i in range(numMessages): for j in M.retr(i+1)[1]: print j f.write(j, "\n") M.quit() print "Mail finished retrieving.\n" f.close()