IMAP email debugging

November 21, 2013

Isn’t it a problem when you have to debug a problem with emails in an existing project? You never know if they are sent and to whom? I just found out that python has an awesome IMAP debugger built in! Just set your project to use these email settings:

IMAP host: localhost
IMAP port: 1025
IMAP user: {leave empty}
IMAP password: {leave empty}

Then you run this in your terminal:

python -m smtpd -n -c DebuggingServer localhost:1025

You’ll now see every mail that’s sent from your application displayed in your terminal!

That’s it… Have fun debugging

Advertisements

Yes, you can use Mozilla’s great e-mail client ‘Thunderbird’ with your Microsoft Exchange account! I’m doing it at work since september now, and it’s working like a charm. Sadly, it’s not very easy to get it to work. We’ll use only free (as in speech) software for this, and this will work on every major operating system (Mac OSX, GNU/Linux, Windows). Here we go!

1. What you’ll need

You can get these programs from their websites, or install them using your favorite package manager.

2. Setup DavMail

First, we’re going to set up DavMail. DavMail is a gateway for the exchange protocol. It will connect to the exchange server for us, and translate everything to standard e-mail and calendar protocols, like IMAP, LDAP, etc… You can then connect Thunderbird to Davmail, instead of connecting it directly to the Exchange server.
The installation of DavMail on every operating system is pretty straightforward, but if you can’t get it installed, there are instructions on the DavMail project site (installation on ubuntu needs a little terminal command to show the system tray icon). Once the program is installed, open the settings panel and fill in the url of your Exchange server in the “URL OWA” field.
http://mail.server.com/owa
Also make sure the ports listed under that field are not in use by other programs, and do not require root permissions. Therefore it’s best to use ports with numbers above 1000.

3. Setup Thunderbird e-mail

If DavMail is installed and set up correctly, you can now install Thunderbird, and add your Exchange account to it. Fill in your name, e-mail address, and password. Thunderbird will most likely try to find your host in it’s database and fail. You’ll have to insert your connection data manually.

First, choose the IMAP protocol. Then, you’ll have to enter hostnames and ports for IMAP and SMTP servers. Use localhost as your host, since the DavMail program is your host and listens on localhost. For the port numbers, insert the portnumbers you chose in the DavMail settings (IMAP will most likely be 2143 and SMTP 2025). As username use your full e-mail address, and as password you should use your e-mail’s password.

If that went right, you can now send and receive e-mails through Thunderbird. But that’s not all there is to Exchange, right?

More info: DavMail howto

4. Setup Thunderbird calendar (Lightning)

Install the Lightning add-on in Thunderbird. Then create a new network calendar. Select CalDav as format, and insert this in the location field (edit the port number, 2080 in my case, to match your DavMail settings, and the e-mail address to match yours):
http://localhost:2080/users/your.name@your.company.com/calendar
Choose a name and a color for the calendar in the next step. After that you’ll be prompted for your username and password. Use your full e-mail address as username and as password you should use your e-mail’s password.

More info: DavMail howto

5. Setup Thunderbird contacts

This will also be handled by DavMail. In Thunderbird, open your address book (‘Contacts’) and click File > New > LDAP Directory
Again, insert the port number you chose in the DavMail settings, and localhost as hostname. Set base context to ou=people, and as user you’ll insert your full e-mail address again. When that’s done, go to Thunderbird’s settings, and in the ‘write’ or ‘compose’ tab, tell Thunderbird to use this directory for address autocompletion.

More info: DavMail howto

That’s it! You can use Thunderbird with your Microsoft Exchange account from now. Say goodbye to Outlook and use the force with Thunderbird! There might be some small bugs here and there, but i’ve been using it for a while now, and never needed outlook for anything. Have fun!

Regards
Toon