The ISPmail tutorial is maintained since 2002. You may have followed former versions of the tutorial and now want to know how to upgrade your mail server to Lenny properly. It is hard to provide exact instructions on what steps to go through. Here are some issues:
Database schema change
I know you'll hate me for that. But the normalized database layout used in the Etch tutorial was overshooting. So this tutorial uses a more human-readable layout which isn't that much different actually. And it's lighter on the database because the former queries used string operations on a view which might get slow on mail servers with very many users. To migrate your database please first make a backup of it (you never know). Then issue these SQL queries which should migrate your database painlessly to the new schema:
-- Create an additional 'email' column in the virtual_users table
ALTER TABLE virtual_users ADD email VARCHAR(100) NOT NULL;
-- Fill the 'email' column with the complete email address.
UPDATE virtual_users LEFT JOIN virtual_domains ON virtual_users.domain_id=virtual_domains.id SET email=concat(virtual_users.user,'@',virtual_domains.name);
-- Remove the 'user' column
ALTER TABLE virtual_users DROP user;
-- Drop the 'view_users' view
DROP VIEW view_users;
-- Enlarge the email fields in the virtual_aliases view
ALTER TABLE virtual_aliases CHANGE source source VARCHAR(100);
ALTER TABLE virtual_aliases CHANGE destination destination VARCHAR(100);
-- Rewrite the source side of the virtual_aliases to the full email address
UPDATE virtual_aliases LEFT JOIN virtual_domains ON virtual_aliases.domain_id=virtual_domains.id SET source=concat(virtual_aliases.source,'@',virtual_domains.name);
-- Drop the 'view_aliases' view
DROP VIEW view_aliases;
You will also need to adjust the ".cf" configuration files as described in the respective chapter.
Mail directories now under /var/vmail
The FHS (file hierarchy standard) suggests to put mails under /var/mail. Previously the tutorial expected to put all mails under /home/vmail but the mail directories do not really belong there. So the new tutorial uses /var/vmail as a location. This issue is a bit nasty as you need to move your Maildirs. This tutorial introduces server-side filtering to allow users to apply pre-defined filters when an email arrives. Dovecot stores these filter files in the user's mail directory so the actual mails need to be moved one level deeper in your directory structure.
It's just cosmetics so you don't have to move your mails there. But if you do it then change the following files:
-
/etc/dovecot/dovecot.conf:
mail_location = maildir:/var/vmail/%d/%n/Maildir
(Early versions of the Etch tutorial didn't use a seperate "Maildir" subdirectory. So if you have an existing directory without that structure you have to create a Maildir folder right there and move all mail folders (cur, new, tmp and all folders starting with a dot there. Otherwise the "sieve"-based filtering described in this tutorial won't work.) -
/etc/dovecot/dovecot.conf:
Check your "namespace private" section to change "/home/vmail" to "/var/vmail".
AMaViS configuration file
Previously the tutorial recommended to put your custom AMaViS configuration into the /etc/amavis/conf.d/20-debian_defaults file. This will make this file risk getting changed during an update. Please move your settings to the /etc/amavis/conf.d/50-user file instead.
Global Dovecot/Sieve config file
In recent Dovecot versions the configuration directory for the global sieve filter file has changed. Previously it was configured as the "global_script_path" in the "protocol lda" section. Now it's the "sieve_global_path" setting in the /etc/dovecot.conf "plugin" section. See also.
Dovecot now creates maildirs automatically
The Dovecot version used in Debian Etch threw errors if a user accessed a mailbox which had not received any email yet. The Debian Lenny version does not have this issue. So you don't have to send the user a "welcome mail" or even create the maildir manually.
Dovecot's configuration file
In the /etc/dovecot/dovecot-sql.conf file you need to change the line
password_query = SELECT email as user, password FROM view_users WHERE email='%u';
to
password_query = SELECT email,password FROM virtual_users WHERE email='%u';
Debian's release notes
Also you should read Debian Lenny's release notes before attempting to upgrade your system from Etch to Lenny.
14 Comments
Maildirectories
Submitted by Anonymous (not verified) on
This is a really nice tutorial (it was worth the waiting ;-))! However, I keep asking myself why to put the maildirectories in /var/vmail and not directly in /var/mail. Although not covered on this page, the same question also applies to the mail user. Why not use the dfault build-in mail user instead of creating an additional one?
Kurt
Overlooked your reason why using /var/vmail instead of /var/mail
Submitted by Anonymous (not verified) on
Hi,
I've overlooked some of the comments listed on page http://workaround.org/ispmail/lenny/configure-dovecot which actually contains the answer to my question (why using /var/vmail instead of /var/mail).
Thanks again for the great tutorial and your time (and apologizes for taking some needles of it)
Kurt
MySQL Error 1062 when dropping 'user' from 'virtual_users'
Submitted by Anonymous (not verified) on
Hallo and thank you for your again excellent work!
I had some difficulties migrating my database from the etch tutorial. Removing the column 'user' didn't work, there was an error 1062, telling me there was an duplicate entry '1' for key '2'.
As I am not very familiar with MySQL and only using it without much of an intrest (whereas I am very much interested in the backgrounds of the rest of this server-system), it took me a while to see that I had to modify the Index 'UNIQUE_EMAIL' from 'user' to 'email' to be able to drop the column.
Maybe you can put this in your tutorial for future readers.
Greetings from Austria!
Martin
bug solution #1062 - Duplicate entry '1' for key 2 drop
Submitted by Anonymous (not verified) on
ADD UNIQUE `UNIQUE_EMAIL` ( `domain_id` , `email` )
thank you very much
Submitted by Anonymous (not verified) on
thank you very much for the info. I was having same issue and your SQL command did the trick.
ALTER TABLE `virtual_users` DROP INDEX `UNIQUE_EMAIL` , ADD UNIQUE `UNIQUE_EMAIL` ( `domain_id` , `email` );
Change vmail home directory as well to avoid permission problems
Submitted by Anonymous (not verified) on
This may be obvious to most of you but if you're migrating from the old tutorial you should also change the user 'vmail's home directory to point to the new /var/vmail instead of /var/mail to avoid the following error message;
<user@example.com>: temporary failure. Command output: Can't open log file
/var/vmail/dovecot-deliver.log: Permission denied
--------------
// change vmail's home dir
sudo usermod -d /var/vmail vmail
// double check /var/vmail perms and update as necessary
ls -ls /var/vmail/
sudo chgrp -R vmail /var/vmail/
sudo chown -R vmail /var/vmail/
-----------------
Database schema change
Submitted by Anonymous (not verified) on
Yes, it's possible to create
Submitted by Christoph Haas on
Impact of views on the mysql server
Submitted by Anonymous (not verified) on
[Warning] Aborted connection ... to db: 'mailserver'
Submitted by Anonymous (not verified) on
Hello, I have been using a mailserver installed after the tutorial "ISP-style email service using Postfix 2.3 (Debian Etch)" for quite some time now, and never had a problem (until now).
Yesterday I updated my Debian from Etch to Lenny. The update showed no errors and everything works fine. I can send and receive E-Mails and the mail-logs (.info, .warn, .err) show no error.
But today I found several of these error-messages in my mysql error-log:
100122 16:45:09 [Warning] Aborted connection 2046 to db: 'mailserver' user: 'mailuser' host: 'localhost' (Got an error reading communication packets)
100122 16:45:09 [Warning] Aborted connection 2045 to db: 'mailserver' user: 'mailuser' host: 'localhost' (Got an error reading communication packets) ..
This problem is only with db: 'mailserver' and user: 'mailuser'. No other database connection has this problem, and there are no errors other than this.
The mail-system is still the version from the debian etch tutorial. I have made none of the changes mentioned above. There have been also no changes with mysql.
Has someone an idea what might be the reason of this error message? Will making the changes mentioned above help in my case?
Thanks for your help!
By the way, the link to the forum (last link on http://workaround.org/ispmail) does not work.
Storing directory
Submitted by Anonymous (not verified) on
Is there a reason to store the mails not in /srv/vmail ?
wingfire
In short terms: no. I didn't
Submitted by Christoph Haas on
In short terms: no. I didn't find any entirely correct directory according to the FSB so I decided to put the emails into /var/vmail. But you can set it to anythin.
/var/vmail/ makes sense to me
Submitted by Anonymous (not verified) on
/var/vmail/ is what I saw being used in another tutorial, so I went with it. It needs a place to live on the file system and since /var/mail/ is what is used on my system for local mail, /var/vmail/ seemed like a good place as well. Makes sense to me anyway.
Dovecot's conf file
Submitted by Anonymous (not verified) on
should be
The "as user" is missing (at least according to the relevant page in the tutorial).