Archive for the ‘postfix’ Category

RoundCube Webmail 0.1-beta changepassword patch

Sunday, May 21st, 2006

When I was deploying the new corporate mailserver I needed to re-install the webmail client. We used to work with SquirrelMail (http://www.squirrelmail.org/), a very decent and extendable webmail client. But we all know that the UI of SquirrelMail is ugly, really ugly.

So after some googling I came across this new great webmail client named RoundCube (http://www.roundcube.net/). This is a new fully featured AJAX-based webmail client with a very slick UI. From the first moment I saw that RoundCube was the way to go.

After I did the installation and played around with the webclient I wanted to extend it and give the ability to my users to change their password. The basic idea was to add a tab ‘Password’ in the settings window. Since I’ve configured my mailserver (postfix) with mysql (user fields are created dynamically) it’s just a matter of updating the correct row in the database and reconnect to the IMAP server (courier-imap).
The only problem is that the framework of RoundCube is creap, and I mean really crap. It took me 6 hours to create the tab and the underlaying forms / code. Not because I work that slow but because it’s not intuitive and you have to mess in 5 files in order to add a new action (Ok, I only worked at night on it so my mind wasn’t that clear but anyway).
Below I’ve attached the patch, so if some of you want to make your own tab you can read through the patch and see how it works.

It uses an external script (ext/change_password_function.inc) with one function in it: change_password_function ($user, $currentpass, $newpass).
In my case, it just updates the postfix mailbox database but you can modify this code to fit your needs (eg. if you use the courierpassd you can connect to the password-daemon and change the user’s password here).
Enjoy it,
Nicolas

RoundCube Webmail 0.1-beta changepassword patch

Running multiple postfix instances on Debian

Sunday, April 2nd, 2006

Recently I needed to reconfigure the company’s mail server in order to comply with the different requirements of Yahoo, Hotmail, AOL, etc.
The only solution for us was to set up multiple postfix instances with different configuration files.

I was surprised how easy that is:
cp –rp /etc/postfix /etc/postfix2
cp –rp /var/spool/postfix /var/spool/postfix2

Add the following line to /etc/postfix/main.cf:
alternate_config_directories = /etc/postfix2

Make sure you change the following in /etc/postfix2/main.cf:
syslog_name = postfix2
queue_directory = /var/spool/postfix2
alternate_config_directories = /etc/postfix

The only thing to do now is to bind the instances to separate IP addresses (or even different ports but I didn’t try that).
In my case I’ve changed the inet_interfaces value into mail1 for the first instance and mail2 for the second one. mail1 and mail2 are entries in my /etc/hosts for 192.168.0.4 and 192.168.0.5. They are both in use by my mail server.

The only difficult part was to hack the /etc/init.d/postfix script to start and stop both instances. I’ve posted my init script and it takes care of the multiple instances.

When you run tools like ‘qshape‘ or ‘mailq‘ they all use the spool directory of the first instance. With some tools you can specify the -c parameter to change to an alternative config directory. For example ‘qshape -c /etc/postfix2‘ will analyze the queue of the second instance. But the tool ‘mailq‘ doesn’t take the parameter -c. There you can set the environment variable ‘MAIL_CONFIG’. Just ‘export MAIL_CONFIG=/etc/postfix2 && mailq‘ et voila. When you use the php mail() function just ‘putenv (”MAIL_CONFIG=/etc/postfix2″);‘ before using the mail() function and your mails will be sent thru the second instance.

Happy mailing,
Nicolas

The hacked postfix init script