Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython

mailserver is unavailable in PyPM, because there aren't any builds for it in the package repositories. Click the linked icons to find out why.

 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1alpha1 Failed View build log
Windows (64-bit)
0.1alpha1 Failed View build log
Mac OS X (10.5+)
0.1alpha1 Failed View build log
Linux (32-bit)
0.1alpha1 Failed View build log
Linux (64-bit)
0.1alpha1 Failed View build log
 
Links
Author
License
BSD
Dependencies
Lastest release
version 0.1alpha1 on Jan 5th, 2011

Develop Mailservices in Django

Django Mailserver is an application that lets you develop mail services in your Django projects/applications in a manner that handles messages as Django handles HTTP requests.

That project was initialy conceived as an improvement over `django-smtpd`_ by Denis Laprise, then became an almost full rewrite and when I thought I had gone through almost every line of code it seemed far much more like a fork than improvement.

NOTE: that this is really alpha software, don't use it in a production environment unless you expect it to break everything ;)

System Message: WARNING/2 (<string>, line 16)

malformed hyperlink target.

Example usage:

First of all, you need to add "mailserver" in your INSTALLED_APPS, and you'll want the settings:

System Message: WARNING/2 (<string>, line 24)

Literal block expected; none found.

ROOT_MAILCONF = 'myproject.mailbox' # Just like ROOT_URLCONF, but for # resolving recipients. MAILER_DAEMON_ADDRESS = 'postmaster@mydomain.com'

ROOT_MAILCONF is just like an URLCONF, but it matches e-mail addresses instead of paths. An example myproject.mailbox mailbox.py file would be:

System Message: WARNING/2 (<string>, line 32)

Literal block expected; none found.

from django_mailserver.mailbox import *

urlpatterns = patterns('', (r'@bugs.example.com', include('myapp.mailbox')), )

Note, that when matching recipients, just as Django strips path elements as they get matches, mailserver strips already matched parts from the addresses until it reaches the views.

Now you can start you mail service! You can either to:

./manage.py startmailapp <app_name>

From your project directory to have a new app created with a sample mailbox.py file in it, or you can create a new mailbox.py file in your existing application:

System Message: WARNING/2 (<string>, line 49)

Literal block expected; none found.

from django_mailserver.mailbox import *

urlpatterns = patterns('', (r'^onedest', 'myapp.mailers.reply'), )

You have it, your mailers.py file would be just like a views.py:

System Message: WARNING/2 (<string>, line 57)

Literal block expected; none found.

from mailserver import EmailResponse

def reply(request): print "Got email %s, Reply!" % request return EmailResponse( from_email=request.get_recipient_display(), to=request['From'], body=request.get_body(), subject="Re: %s" % request['Subject'])

You get the idea, if you return an EmailResponse it gets send() later by the Handler. You can also return EmailIgnoreResponse among others.

Delivering mails

Right now the only possible way to deliver messages to this is through a pipe transport to the ./manage.py readmail command. Which is mostly intended for testing.

Further improvements should have a more performant pipe transport and a self-running SMTP server.

TODO

WARNING: Django Mailserver is still under development. It is believed to brake at any point ;) There are lots of things to do, like:

  • Documentation
  • More tests.
  • Better URL parsing (i.e: includes work on domains, others on addreses).
  • Handling address prefixes/suffixes
  • Handling of error responses (ie: pipe transport should bring the

System Message: WARNING/2 (<string>, line 91)

Bullet list ends without a blank line; unexpected unindent.

response status_code to the exit value of the process).

Docutils System Messages

System Message: ERROR/3 (<string>, line 8); backlink

Unknown target name: "django-smtpd".

Subscribe to package updates

Last updated Jan 5th, 2011

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.