My favorites | Sign in
Project Home Wiki Issues Source
Project Information
Members
Featured
Wiki pages
Links

This is another attempt to make a webmail app in python. I aim on a first stage to build a standards compliant imap webmail client with the basic functionality we can find in squirrelmail without plugins. I'm not too worried about the user interface since it will be extremely easy to use the Django project templates to customize it.

Contact / Support

If you which you can also write to "hguerreiro at gmail dot com" if you have any comments about this project.

What's done?

"simples" theme, a work in progress:

Django based webmail client

The implemented features are:

  • Multiple IMAP and SMTP server support;
  • IMAP authentication, the Django built-in auth is only used for the superuser;
  • Auto creation of django users - if the user successfully authenticates against the IMAP server then a new django user is created '<user name>@<imap host>';
  • Mailbox List (subscribed mailboxes);
  • Folder List;
  • Message List (paginated);
  • Message view, only the TEXT/PLAIN parts, the others, including the html parts, may be viewed/downloaded from the message view;
  • Reply, Reply to All, Forward, Inline Forward;
  • Move and copy messages;
  • Message composing in plain text or using Markdown that's converted to html when the message is sent;
  • Simple address book application, it supports server, site and user level address books. The user can only edit and delete is own addresses. The server and site level addresses can be created from the admin interface;

Please note that I'm using Cyrus and Gmail to test, so if you try to use this on another kind of server the results may not be the same.

Bug reports and patches are welcome!

IMAP library - imaplib2

The IMAP proto is a bit complex, for me, the most difficult part in dealing with IMAP is to efficiently parse the server responses and within the IMAP responses the FETCH command ones are really complicated. Right now we parse to a useful format almost all the responses sent by the server.

For instance:

  • BODYSTRUCTURE FETCH responses are transformed in a class hierarchy, it's easy to get the part numbers for each part and then get only those message parts in which we're interested;
  • ENVEVELOPE FETCH responses are transformed in a dict;

Besides this, we can also get unasked for responses from the server, these are parsed correctly and stored on a response structure from where they can be read.

Finally, the optional codes and tagged responses are also stored in a log, and callback functions can be defined to react to these responses.

Higher Level IMAP library - hlimap

In order to have a more intuitive and simpler way to deal with the IMAP complexity, I've added an extra layer on top of imaplib2. Since this is being developed parallel to the Django webmail client, the result is that it's very easy to use from a Django template. For example to make a message list view, the Django view code to get the necessary information is:

M = ImapServer('example.com')           # Connect to the server
M.login('example user','example pass')  # Login
folder = M.folders[folder].select()     # Get the folder and select it
folder.messages.change_search(criteria) # Change the search criteria
msg_len = folder.messages.len()         # To do the pagination
[...]
message_list = folder.messages[i:j]     # Get the message list 

On the django template we do something like:

{% for msg in message_list %}
    <p>{{ msg.envelope.env_date }}
    <p>{{ msg.envelope.env_subject }}
{% endfor %}
Powered by Google Project Hosting