Configure your virtual machine to deliver email locally (using postfix, cyrus, imap, and sasl)
I do almost all of my development on Centos virtual machines. This allows me to keep my filesystem, databases, and server configurations contained in a separate environment without harming my host operating system (OSX). This morning, I encountered a problem with my email not being delivered properly. I’m assuming this happened because my virtual machine is not a full qualified email server. I figured the easiest solution would be to setup my virtual machine as an IMAP server instead of trying to fight with DNS, static IPs, spam filters, etc. When it comes down to it, all I need is for my emails sent from my web applications to end up in my email client inbox. Here’s what I did to get this to work…
Ditch sendmail and install postfix. Postfix is much easier to configure; Sendmail is jibberish.
Install cyrus IMAP service. NOTE: SASL will be the authentication method service
Configure Postfix service
Configure Cyrus
Add a new IMAP account in your favorite email client. For my setup, I used the IP address of my virtual machine as the incoming mail server address. Now, when mail is delivered from my virtual machines, it is delivered locally and my email client is used to fetch the new messages!
To ensure your setup is working properly, you can send a quick email from the command line (on your virtual machine)
Update 2009-01-21
I just tried to follow my own procedure to configure my new virtual machine and I could not authenticate using cyradm. I kept getting this error:
cyradm: cannot authenticate to server with as cyrus
Once I set the password for the cyrus user, It worked.