Writing a Python mail server with authentication - python

I'm trying to write a simple mail server using Python.
I found smtpd that can be used as a simple smtp server, but I don't think it supports any form of authentication.
For pop or imap, I haven't found anything at all yet.
I do know Twisted has some support for both smtp and pop or imap, but I can't find any examples or tutorials about it.
An alternative would be to use Clojure, but I still have the same question:
Which libraries should I use and is there any documentation about them?

Here is an example from Twisted.
And the main page. Follow the link for documentation to find the example and a tutorial.
Edit:
Check the attachment for this ticket for an example IMAP server. Definitely read the thread as it talks about the shortcomings of the example.

A bit late probably but for experimentation you might also want to check pymta which is a pure-python SMTP implementation I'm using for some experiments/testing. It supports SMTP basic auth. Documentation should be at a 'decent' level, check the examples directory and the unit tests-
For anything production-related I'd go for twisted if you don't mind the asynchronous nature.

Related

How to send email with Do Not Forward flag using exchangelib

This is similar to How to set/access outlook DoNotForward property in Microsoft exchange service but I want to use the exchangelib Python module to send emails.
The building blocks and links to documentation are available in this exhangelib issue: https://github.com/ecederstrand/exchangelib/issues/540
In short, it's really tricky to do if you are not using a Microsoft-supplied library. You have to build a binary message with all sorts of magic variables and send that as a custom extended property. Plus you have to implement the client-side encryption needed by EWS rights management.
AFAIK, no-one has attempted a Python solution yet, and a full solution would require quite a bit of work.

Django SMTP and secure password authentication

I have an SMTP server that requires secure password authentication (e.g. Outlook requires to check SPA). Is there a way to deal with it with Django SMTPConnection?
Or maybe ideas about any python solution to deal SPA?
Honestly, I couldn't find enough about SPA, to understand what is it exactly:
en.wikipedia:Secure_Password_Authentication
http://www.kuro5hin.org/?op=displaystory;sid=2002/4/28/1436/66154
The python-ntlm project is a working implementation of NTLM authentication for urllib2. There is a patch floating around in the tracker that allows integration with smtplib.
I would install python-ntlm, then fork smtplib inside your Django project (making sure it gets imported through smtplib) and then patch either smtplib (to always use ntlm authentication) or django (to use python-ntlm).
This will get the work done.
After googling for it I found the same question asked on Google Groups:
http://groups.google.com/group/django-users/browse_thread/thread/fc7f77e2f796e6a4/90ae093cbb2863b8?pli=1
SPA is a proprietary MS protocol for
which there is no documentation. I
don't think you will find a non MS
implementation of SPA.

Best method of connection between automated python XMPP server and interface to django?

I have an XMPP server (likely — python, twisted, wokkel), which I prefer not to restart even in the development version, and I have some python module “worker” (which is interface to particular django project), which gets jid and message text and returns some response (text or XML, either way).
The question is, what would be the best way to connect them, considering that I may prefer to update the module part too often?
Another consideration is that it might be required to run multiple instances of “worker” for it all to be high-load-capable.
One possible way I see is implementing a thread in the server which checks if the module was changed and reload()s it if necessary.
The other way would be making something similar to fastcgi through sockets, although not HTTP-based.
My suggestion is:
Use RabbitMQ with XMPP adaptor.
Use Python carrot for AMQP since it can be used directly under Django.
I can't say that I understand all of your question, but the bit where you're asking how to connect django and twisted and multiple workers: I'd suggest using AMPQ. This gets you reliable message delivery, multiple consumers, persistence.
There's the txAMQP library for twisted.
https://launchpad.net/txamqp
A good primer to AMQP here, it's a good place to start:
http://blogs.digitar.com/jjww/2009/01/rabbits-and-warrens/

twisted http client

I am after an example describing the usage of Twisted's HTTP Client.
After reading the excellent blog post on the internals of Twisted, I understand how the "Factory" and "Protocol" components play their role but I am unclear on how to introduce "Request" in the overall Client flow.
More specifically, I need to be able to perform HTTP GET and POST requests to a remote server using Twisted.
Updated: after a discussion on irc #twisted / #python, it seems that twisted.web2 is fading away in favor of beefing up functionality on twisted.web e.g. Agent.
As of Twisted 9.0, there are actually two HTTP clients available. The older one has quite a few features, such as automatically following redirects, interpreting cookie headers, etc. You can find an example of its usage here:
http://twistedmatrix.com/documents/current/web/examples/
(getpage.py and dlpage.py)
Unfortunately, the interface presented by the older client makes a number of common tasks difficult. For example, using getPage, you cannot examine arbitrary response headers.
The newer HTTP client isn't yet as featureful as the old one, but it presents an interface intended to eliminate the limitations of getPage. It is also intended to be more easily extended and customized. You can find a document describing its usage here:
http://twistedmatrix.com/documents/current/web/howto/client.html
I started using treq with twisted. treq has an API which is very similar to Requests.
https://pypi.python.org/pypi/treq/0.2.0
As of Twisted 10, you may want to use the Agent class.
Please follow this link:
http://twistedmatrix.com/documents/10.2.0/web/howto/client.html

where to start OpenID implementation in python,which API is better suits

im using python API in our research project.i read lot of ppt and material, and finally understand this concept now i have task to execute simple function which is chek user credential thorough openid provider and return successful after the valid user check.....
To add to the recommendation of the Python OpenID library: their docs pages for the server and consumer modules both have useful Overview sections which you should read as a good starting point. The examples directory is also useful; I've written things starting from server.py and consumer.py from there.
Why not use Python OpenID library?

Categories