[Tutor] Recieving emails in python

Shane Geiger sgeiger at ncee.net
Mon Jan 14 07:53:41 CET 2008

mobiledreamers at gmail.com wrote:
> I m trying to create something simple a mailing list similar to yahoo
> groups
> I m stumbling at the part where the python recieves messages via say
> python at yahoogroups.com <mailto:python at yahoogroups.com>
> how to make python recieve emails and process it
> after that it is straight forward processing in python inserting in db etc

Can you use POP to access Yahoo groups?

If so, this script will get you started:

Redirect the output to a file to capture the contents of the mailbox.
host = 'foo.com'
account = 'jennyjenny'
password = '8675309'

import getpass, poplib
M = poplib.POP3(host)
numMessages = len(M.list()[1])
for i in range(numMessages):
    for j in M.retr(i+1)[1]:
        print j

Shane Geiger
IT Director
National Council on Economic Education
sgeiger at ncee.net  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy

More information about the Tutor mailing list