Wednesday, November 24, 2010

OpenBSD NC4200: Getting Alpine to work with DavMail.

Firstly, yeah I changed the blog's title. As I'm using ONLY OpenBSD nowadays, I think it's appropriate to change the title as I don't use other type of BSD. Now back to the main story.

So far, this is a brief description of what I (initially) wanted to achieve:

Alpine+LDAP <---> DavMail <---> CompanyEmail@OWA/Exchange

So here's what I'm currently doing. Getting Alpine + DavMail to play nicely together. I have posted earlier that I compiled my Alpine with LDAP support so I can check my company's email address book. Here's the current status of the project:

DavMail <---> CompanyEmail@OWA: Working fine
Thunderbird <---> DavMail: Working fine

As DavMail is working, I can just focus on configuring Alpine. The first time I start Alpine (by typing Alpine in xterm), the program will create ~/.pinerc configuration file. I don't need to blow my head to configure Alpine as it has a great built-in configuration tool.

Chapter 1: Receiving emails.
Inside Alpine's Main menu [M], I just key [S] (Setup), [L] (collectionLists). Then inside Alpine's Setup Collection List page, I hit [A] (Add collection). Here's my configurations:

Nickname: MyCompany
Server: localhost:1143/user=ASIA\karl

After I save & exit the configuration [Ctrl+X], Alpine requested for my email's password. I keyed in my password and Alpine ask for confirmation to exit the page. No error messages, so it's all good. Now to test it.

I go to Main [M], then hit [L] (Folder List). I can see 2 folders:

   Local folders in mail/

   Folders on localhost:1143/user=ASIA\karl in home directory

I choose MyCompany and using the Right Arrow [>] key, Alpine opened up my company email. I can see all the folders I have there and I can read my emails. So far so good.

Chapter 2: Sending emails (Working now!).
I'm still configuring this part as it's not working. I'll just put the steps for revising purpose. If you have a working solution, do comment.

Thanks to Christopher for commenting and posting a usefull link. Surely, I managed to tweak Alpine's setting and managed to get the SMTP portion working for sending emails. Do take note that I'm already running a new version of DavMail so it'll be better for you guys to update too.

Inside Alpine's Main menu, I choose [S] (Setup) and [C] (Config). The mandatory line to be update is this:

SMTP Server (for sending) = localhost:1025/user=ASIA\karl

So here, I don't need to use user=ASIA\\karl because the single \ is not escaped.
As I stated, it's currently not working. I kept getting "Error sending" message if I want to send out email. Previously I tried user=ASIA\karl but the "\" got escaped in ~/.pinerc and I still can't send email.

If I can't sort this out, I might have to go with using Sendmail instead of going thru DavMail. I will post any updates on this. I've also added this line in the same Config's screen:

Inbox Path = {localhost:1143/user=ASIA\karl}inbox

Note that this setting depends on whether you need it or not. As I use Alpine only for 1 OWA account, I set this up. Now press [E] to exit and save the setting. Press [Q] to quit Alpine.

Now vim your .pinerc file, normally in your home folder (~/.pinerc) and change this line:


Save the .pinerc file and open Alpine back. I composed [C] an email and wallah! Alpine asked for my OWA password and email is sent! Great!. Again, thanks Christopher!

Chapter 3: Using LDAP.
As I've compiled my Alpine with LDAP support, I can use it to search my company's email address book. Inside Alpine's Main menu, I choose [S] (Setup) and [D] (Directory). Inside Alpine's Setup Directory Servers page, I hit [A] (Add dir) and this is my settings:

ldap-server= localhost
search-base= ou=people
port= 1389
bind-dn= ASIA\karl
nickname= MyCompany

Then I hit [E] (Exit Setup) and [Y] to save changes. [E] to exit the Setup Directory Servers page.

To test out, inside Alpine's Main menu, I hit [A] (Address Book) and select MyCompany. I hit the Right Arrow [>] key and type a name to search. Alpine then requested for my password and after a while, list of matches appears. So this part is working too.

Chapter 4: Offline email reading.
Yes, there's no offline reading for Alpine using IMAP. So now I know. That's one of the most important feature I wanted to use. After searching for solutions, I found the most suitable option. This is the latest description of the (possible) solution:

Alpine+LDAP <---> UW-IMAPD <---> OfflineIMAP <---> DavMail <---> CompanyEmail@OWA

So, instead of getting Alpine to directly access DavMail, Now I need to set up UW-IMAPD and OfflineIMAP. UW-IMAPD is built as dependency for Alpine+LDAP. UW-IMAPD is a local IMAP server and OfflineIMAP is like what the name means, reading emails from IMAP server in offline mode. Now OfflineIMAP will retrieve emails from my company's exchange thru DavMail (OfflineIMAP can't directly retrieve exchange emails), then OfflineIMAP will sync the emails to my local IMAP server which is UW-IMAPD so I will have a local offline copy of my emails that I can use with Alpine. Here's the checklist of needed softwares:

- Alpine+ldap
- DavMail
- OfflineIMAP

Update 13/04/11: Thanks to Christopher's comment, I got my email sending working! Thank you very much! You guys should read his comment and go to the link posted. I've update this post to reflect the changes. Later then.


Unknown said...

I'm having troubles with alpine sending mail through a davmail server also. It appears that the authentication method used is not favoured by davmail, and it simply rejects it. I cannot for the life of me see a different way to authenticate with SMTP, maybe someone else knows? Seems like a trivial error.

George T said...

Thanks for sharing your successes with this project. I've also gotten Thunderbird to work with DavMail. Alpine, though, seems to have trouble connecting. I keep getting login authentication errors after entering my username and password.

Perhaps Alpine can't properly parse the backslash between my domain and username.

Unknown said...

I have found salvation at this link:

As I hoped, only a couple of trivial changes are needed. Cheers!

Karl said...

Thanks Christopher! The link you've posted is really useful. I now managed to get my Alpine to send email. Note that changes has been updated in the post. Thank you very much.

Martin said...


Thank you very much for sharing your experiences.

Following the steps above I succeeded to get Alpine working with
Davmail on Ms Windows very well.

It seems to me important to accentuate here that, at least on MS
Windows, when installing Alpine it must be selected the option to save
the configuration file (.pinerc) locally and not on the server, that is
the default, because it is this file which has to be edited as you
explain, to get SMTP working properly.

In Alpine's setup I selected the option to use an external editor and
added its path "\to\my\emacsclientw.exe", that is more comfortable
especially for spell checking in languages other than English.
Actually I wanted to use Emacs also to manage my mails, but being on
Windows, Alpine is the better solution to read also html messages.



Anonymous said...

Thanks for the post. I was having issues with sending. I disabled the authentication methods, however, two copies of the message were showing up in the Sent folder, one from Alpine and one from the exchange server. Options for this are to set no FCC or to relay directly through the exchange server if they have smtp or smtps open. I did the latter.

BTW, fwiw, I have alpine checking four separate mail accounts, including my exchange account.

Brad said...

Very helpful! Thanks much.

6.5 amd64: Modify existing certbot certificates.

Hi, It's been quite some time eh. As you can see, I still upgrade my OpenBSD system regularly but currently I do not have the time to ...