Need an example of a POP3 Server or IMAP Server written in Python [closed]
Asked Answered
F

4

7

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.

Floriated answered 18/11, 2010 at 12:37 Comment(1)
May I ask, what was the "'off the shelf' server solution that serves up email as IMAP4 and sends out as SMTP"?Bellarmine
S
6

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

Swat answered 18/11, 2010 at 13:49 Comment(2)
Thanks for the definitions. Missed the question though. You got any python examples for POP or IMAP?Floriated
Give you a +1 on that for your response. I did check out the twimapd, but its for delivering twitter messages, and not actually acting a a "proper" IMAP server. It would need some work to make it work correctly.Floriated
A
2

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

Aviation answered 6/1, 2011 at 3:40 Comment(0)
F
1

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.

Fender answered 19/11, 2010 at 14:50 Comment(1)
0.30, damn thats early days for a mail server. Think I will stick to my open source, "off the shelf". What I was initially after, was a python server, I could inject some plug ins etc. I couldn't find one so was going to write my own. The SMTP bit was a doddle with "batteries" however, the IMAP/Pop stuff was just too much hassle.Floriated
C
1

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

Convolution answered 1/1, 2012 at 19:28 Comment(1)
Indeed, the Lamson project seems to be dead since March 2013. Instead, focus seems to have shifted towards Mailman3, specifically the Mailman Core in this case.Convolution

© 2022 - 2024 — McMap. All rights reserved.