Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need an example of a POP3 Server or IMAP Server written in Python

Experimenting with Application Messaging over email for Applications. I have already created my SMTP Server but now missing a centralised delivery mechanism. I can create a propriety delivery mechanism very easily but I am trying to use protocol standards. I am not interested in HTTP, FTP or SOAP but only the mail protocols.

I have looked around the net for python examples, so far no luck. I don't want to spend too much time and effort into this, as its only a technique field study for the moment, to see if async delivery over an email system is a viable approach to communications between applications. I know about sendmail solutions and I am not interested in this, as the solution needs to be a full on Python solution, using "batteries" where possible, or maybe Twisted if I really have too.

The only two standards I have looked into thus far is IMAP and POP. I still can't believe that in this day and age we require two protocols for mail sending and delivery, if there is anything out there that does the two in one (Protocol that is) I would be most happy to look into it.

After further investigation, I think that the only viable option would be twisted, any help with this would be great

update Gave up on the POP/IMAP Server, its all a little bit too much work for very little reward. However, I used an "off the shelf" server solution that serves up email as IMAP4 and sends out as SMTP. Now that I have found this, I will continue my investigation of Application Services over Email. So far created an application that downloads RSS feeds and emails them in html format. The emails are filtered for content I am interested in by a server application written in Python. Next stage is a DSL language to communicate with a server, bit like telnet over email. Should be fun. After that RPC over Email between multi applications.

like image 285
WeNeedAnswers Avatar asked Nov 18 '10 12:11

WeNeedAnswers


4 Answers

Edit: A simple example of a POP3 server can be found here: http://code.activestate.com/recipes/534131-pypopper-python-pop3-server/ You will have to replace the message serving mechanism, but you would need to do that anyway. For an IMAP server implementation using Twisted, see https://github.com/davglass/twimapd .

If you want email, then you're looking at SMTP, POP and IMAP. That's what email is by definition.

Actually, for delivery, SMTP should be enough; POP/IMAP is for retrieval and is not really that useful if your applications can always connect to each other directly.

If you don't need to use email specifically, you might want to look into alternative protocols, such as XMPP (Jabber): http://en.wikipedia.org/wiki/Extensible_Messaging_and_Presence_Protocol

like image 171
Gintautas Miliauskas Avatar answered Sep 26 '22 00:09

Gintautas Miliauskas


I wrote a simple email based message queue for application to application communication. You can find the details here http://blog.bootstraptoday.com/2010/11/28/really-simple-python-message-queue/

Basic idea is 1. Derive a class from smtpd.SMTPServer. 2. Override ‘process_message’ method. 3. In ‘process_message’ start a thread. 4. Inside the thread function, read the message contents and execute the task. 5. The message contents are simple JSON objects. 6. Client code is simple. Client just have to send a ‘email’ to this local SMTP server. Send the task parameters encoded in JSON format as content of this email. So the client can be a simple shell script.

In all it was about 40-50 lines of python code.

Somewhat similar idea but much more sophisticated implementation check Lamson : Deferred Processing To Queues

like image 25
Nitin Bhide Avatar answered Sep 24 '22 00:09

Nitin Bhide


Quotient is a messaging server which includes email support based on Twisted. A few years ago development started over on a new database layer, and the most recent version supports SMTP and POP3. The older version has IMAP4 support, though.

like image 20
Jean-Paul Calderone Avatar answered Sep 23 '22 00:09

Jean-Paul Calderone


Looks like you want to play with Lamson and back it with Postfix (+Cyrus, optionally).

like image 33
Amir Avatar answered Sep 26 '22 00:09

Amir