Fully functioning email client in Python

I

iaoua iaoua

Hi all,

I'm a complete newbie to this newsgroup and to Python (pretty much) so
please be nice and give me a warm welcome.

First of all please allow me to properly introduce myself. My name is
James Christian and I am a PhD student at the University of Essex in
England doing research on Machine Translation. You can see my
minimalist homepage at http://privatewww.essex.ac.uk/~jcread

Aside from machine translation I also have other AI related research
interests that have led me to seek the wisom of Python users and
developers on this newsgroup. In a nutshell my problem is this. I have
developed an intelligent conversational agent which dialogues with a
user to find out what they are really searching for. The domain is
open and helps the user find which businesses/websites offer the
services or products the user is looking for according to needs
elicited from the user during the dialogue. I have small but growing
base of experimental users who want to access the agent via email (the
agent can be quite slow at times due to the complexity of the system)
so that they can ask questions and forget about them until an answer
comes to their inbox. And so I need to extend my agent so that it can
receive and send emails and extract the relevant text answers to
questions from the user. This requires full threading capabilities and
automatic text extraction of only the new and relevant material (minus
signatures of course).

Now, I'm not completely lazy and so I have already done a little
homework. I've been reading O'Reilly's Programming Python and
Foundations of Python Network Programming which have both been very
helpful in ascertaining that Python is a strong candidate solution.
Both books talk about the email (for message and header construction
and parsing) sendmail (for sending mail via SMTP) and poplib (for
receiving mail with POP3) libraries.

However, as you can imagine I already really quite have my work cut
out with maintaining and expanding the dialogue of the system and with
the research on Machine Translation.

What I really need is a ready made fully functional Python client that
already has it that offers me a simple interface to extract text from
received messages along with a message id that I can use to associate
the response to a question with and allows me to send out new
questions or answers along with a message id I can use to track future
responses with. I need something that already has the whole shebang.
Can support POP3, IMAP, SSL authentication, message threading etc.

Can anyone point to something that will save me the effort of building
this thing from scratch and first principles? Thanks in advance for
any useful suggestions.

James Christian
 
J

Jorgen Grahn

.
In a nutshell my problem is this. I have
developed an intelligent conversational agent which dialogues with a
user to find out what they are really searching for. The domain is
open and helps the user find which businesses/websites offer the
services or products the user is looking for according to needs
elicited from the user during the dialogue. I have small but growing
base of experimental users who want to access the agent via email (the
agent can be quite slow at times due to the complexity of the system)
so that they can ask questions and forget about them until an answer
comes to their inbox.

OK, so the "agent" becomes a server with a mail interface.
And so I need to extend my agent so that it can
receive and send emails and extract the relevant text answers to
questions from the user. This requires full threading capabilities and
automatic text extraction of only the new and relevant material (minus
signatures of course).

Now, I'm not completely lazy and so I have already done a little
homework. I've been reading O'Reilly's Programming Python and
Foundations of Python Network Programming which have both been very
helpful in ascertaining that Python is a strong candidate solution.
Both books talk about the email (for message and header construction
and parsing) sendmail (for sending mail via SMTP) and poplib (for
receiving mail with POP3) libraries. ....
What I really need is a ready made fully functional Python client that
already has it that offers me a simple interface to extract text from
received messages along with a message id that I can use to associate
the response to a question with and allows me to send out new
questions or answers along with a message id I can use to track future
responses with. I need something that already has the whole shebang.
Can support POP3, IMAP, SSL authentication, message threading etc.

Can anyone point to something that will save me the effort of building
this thing from scratch and first principles? Thanks in advance for
any useful suggestions.

I imagine your only worry is the server side. What are your
requirements on the system it's running on?

If it's on Unix you don't need to do any network programming at all,
and can forget about IMAP, POP3, SSL and SMTP. Using procmail you can
arrange to start a program of your choice each time a mail arrives
(and that program would put the message on your agent's work queue).
To send mail, you feed the text and the recipient address into
/usr/lib/sendmail.

If you build the interface on POP3 and SMTP, you have to bypass the
system's builtin mail capabilities.

If on the other hand it's on Windows, there's certainly some very
different scheme you have to follow (or bypass).

/Jorgen
 
S

Steven D'Aprano

What I really need is a ready made fully functional Python client [...]
Can anyone point to something that will save me the effort of building
this thing from scratch and first principles? Thanks in advance for any
useful suggestions.

Have you searched PyPI for something suitable?


http://pypi.python.org/
 
J

John Nagle

What I really need is a ready made fully functional Python client that
already has it that offers me a simple interface to extract text from
received messages along with a message id that I can use to associate
the response to a question with and allows me to send out new
questions or answers along with a message id I can use to track future
responses with. I need something that already has the whole shebang.
Can support POP3, IMAP, SSL authentication, message threading etc.

It sounds like you need an SMTP receiving server and an SMTP sender,
not a user-type client. See

http://docs.python.org/library/smtpd.html

for a simple server that will handle incoming messages, and

http://docs.python.org/library/smtplib.html

for an SMTP sender that can reply to them. Those are standard
Python functions.

You can run this on most server-type machines. It's best
if you have an upstream server configured to do spam filtering
and forwarding to your server, or you'll get vast amounts of
junk coming into your system.

Have the upstream machine forward to a nonstandard mail
port (like "example.com:2525") if the server machine already
has a mail server. This will allow the existing mail server to
run.

John Nagle
 

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

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top