Receiving emails with attachments

T

tomer.ha

Hi there,

I'm new to Python, but know other scripting and programming languages.
I
want to develop a script which will receive emails with attachments
from my POP3 account, perform certain actions on it and email it back
to someone else.

However, I'm not familiar with any Python library which does it. Could
you a guide me to a relevant library which can handle emails?

I haven't decided yet what scripting language I will use, so a nice
module for Python will probably make me choose it over Perl. :)

Thanks in advance. :)
 
G

Gerard Flanagan

Hi there,

I'm new to Python, but know other scripting and programming languages.
I
want to develop a script which will receive emails with attachments
from my POP3 account, perform certain actions on it and email it back
to someone else.

However, I'm not familiar with any Python library which does it. Could
you a guide me to a relevant library which can handle emails?

I haven't decided yet what scripting language I will use, so a nice
module for Python will probably make me choose it over Perl. :)

Thanks in advance. :)

poplib module:

http://docs.python.org/lib/pop3-example.html

some example code that I wrote when I was starting Python:

http://gflanagan.net/site/python/pagliacci/PopClient.html

( YMMV with this - it works for me but the emails I handle with it are
mostly from a single company and attachments are only ever MS Word or
MS Excel )

I don't know about sending mails.

Gerard
 
T

tomer.ha

Gerard,

I tried to run your code but my interpreter couldn't locate the
maildocument module. Is it included in Python standart library or
should I install it from other place?

Thanks,
Tomer
 
G

Gerard Flanagan

Gerard,

I tried to run your code but my interpreter couldn't locate the
maildocument module. Is it included in Python standart library or
should I install it from other place?

Thanks,
Tomer

Sorry Tomer,

I was just suggesting you read it through as an example, didn't think
you'd be interested in the whole shebang! PopClient was part of a
half-baked project whose intent was to keep an eye on my technology-shy
parents' emails and - wait for it - *post* them any attachments that
were important!! Emails they can do, attachments not. But it was a good
learning exercise.

All the necessary files are here:

http://gflanagan.net/site/python/pagliacci/

Coming from C# I was used to 'one class - one file', but this will be
updated one of these days.

This is the particular file you want:

http://gflanagan.net/site/python/pagliacci/MailDocument.html

which requires:

http://gflanagan.net/site/python/pagliacci/ElementWrapper.html

and both these require the elementtree package which will soon be part
of the standard library, but now you can get it here:

http://effbot.org

( I also have a simple viewer based on XSLT, CherryPy and a CherryPy
filter called Picket but it's not very sophisticated.)

Hope that's enough to get you started.

Gerard
 

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top