Hi, I'm trying to convert users from a sendmail server to a postfix/dovecot server. All works fine but one of the last things is to rescue the messages in /var/mail/<user> on the old server. This seems very straitforward using the convert plugin but with the settings from the wiki, nothing happens when the user logs in. Do I need a private namespace for this as suggested elsewhere in the wiki?
I experimented with mb2md.pl and that seems to do what we need but having the old mail converted upon login is much more attractive. In that way we hope that we can also find some 'dead' users.
TIA Egbert Jan
Egbert wrote on 29.07.2010:
Hi, I'm trying to convert users from a sendmail server to a postfix/dovecot server. All works fine but one of the last things is to rescue the messages in /var/mail/<user> on the old server. This seems very straitforward using the convert plugin but with the settings from the wiki, nothing happens when the user logs in. Do I need a private namespace for this as suggested elsewhere in the wiki?
No hint in the logfile? Maybe a permission problem or Dovecot can't find any emails? If nothing is logged maybe it helps when you set "mail_debug=yes" in dovecot.conf?
Btw: it seems that in the upcoming Dovecot 2.0 version there's no convert plugin available anymore - with 2.0 you can use "dsync" to convert emails between different mailbox formats.
-- Daniel
Op 30-7-2010 0:07, Daniel Luttermann schreef:
Egbert wrote on 29.07.2010:
Hi, I'm trying to convert users from a sendmail server to a postfix/dovecot server. All works fine but one of the last things is to rescue the messages in /var/mail/<user> on the old server. This seems very straitforward using the convert plugin but with the settings from the wiki, nothing happens when the user logs in. Do I need a private namespace for this as suggested elsewhere in the wiki?
No hint in the logfile? Maybe a permission problem or Dovecot can't find any emails? If nothing is logged maybe it helps when you set "mail_debug=yes" in dovecot.conf?
Btw: it seems that in the upcoming Dovecot 2.0 version there's no convert plugin available anymore - with 2.0 you can use "dsync" to convert emails between different mailbox formats.
-- Daniel
Yeah, the obvious place to look. There I found out that the plugin looks for a direcory in /var/mail/ called <user> and in that directory a mailfile called 'inbox' is expected. So I have now the convert in imap and pop3 chapters of dovecot.conf and enabled the plugin in the plugin section:
protocol imap { mail_plugins = convert } protocol pop3 { mail_plugins = convert } plugin { convert_mail = mbox:/var/mail/%u }
So things finally start to work. Only the rename of the /var/mail/<user> directory doesn't work yet. Wrong owner. I made /var/mail owned by vmail:vmail but that is not good. Maybe it should be owned by dovecot. Who is the owner of the convert process?
EJ
Egbert wrote on 30.07.2010:
Op 30-7-2010 0:07, Daniel Luttermann schreef:
Egbert wrote on 29.07.2010:
Hi, I'm trying to convert users from a sendmail server to a postfix/dovecot server. All works fine but one of the last things is to rescue the messages in /var/mail/<user> on the old server. This seems very straitforward using the convert plugin but with the settings from the wiki, nothing happens when the user logs in. Do I need a private namespace for this as suggested elsewhere in the wiki?
No hint in the logfile? Maybe a permission problem or Dovecot can't find any emails? If nothing is logged maybe it helps when you set "mail_debug=yes" in dovecot.conf?
Btw: it seems that in the upcoming Dovecot 2.0 version there's no convert plugin available anymore - with 2.0 you can use "dsync" to convert emails between different mailbox formats.
-- Daniel
Yeah, the obvious place to look. There I found out that the plugin looks for a direcory in /var/mail/ called <user> and in that directory a mailfile called 'inbox' is expected. So I have now the convert in imap and pop3 chapters of dovecot.conf and enabled the plugin in the plugin section:
protocol imap { mail_plugins = convert } protocol pop3 { mail_plugins = convert } plugin { convert_mail = mbox:/var/mail/%u }
So things finally start to work. Only the rename of the /var/mail/<user> directory doesn't work yet. Wrong owner. I made /var/mail owned by vmail:vmail but that is not good. Maybe it should be owned by dovecot. Who is the owner of the convert process?
EJ
I think that vmail should be the correct user/group for this but it could be a problem if the source and destination directories are the same (home directory is the same as mail_location).
Have you set a different mail location? I think Dovecot can't rename the old directory if the new mail location is in the same directory.
-- Daniel
Op 30-7-2010 14:45, Daniel Luttermann schreef:
Egbert wrote on 30.07.2010:
Op 30-7-2010 0:07, Daniel Luttermann schreef:
Egbert wrote on 29.07.2010:
Hi, I'm trying to convert users from a sendmail server to a postfix/dovecot server. All works fine but one of the last things is to rescue the messages in /var/mail/<user> on the old server. This seems very straitforward using the convert plugin but with the settings from the wiki, nothing happens when the user logs in. Do I need a private namespace for this as suggested elsewhere in the wiki?
No hint in the logfile? Maybe a permission problem or Dovecot can't find any emails? If nothing is logged maybe it helps when you set "mail_debug=yes" in dovecot.conf?
Btw: it seems that in the upcoming Dovecot 2.0 version there's no convert plugin available anymore - with 2.0 you can use "dsync" to convert emails between different mailbox formats.
-- Daniel
Yeah, the obvious place to look. There I found out that the plugin looks for a direcory in /var/mail/ called<user> and in that directory a mailfile called 'inbox' is expected. So I have now the convert in imap and pop3 chapters of dovecot.conf and enabled the plugin in the plugin section:
protocol imap { mail_plugins = convert } protocol pop3 { mail_plugins = convert } plugin { convert_mail = mbox:/var/mail/%u }
So things finally start to work. Only the rename of the /var/mail/<user> directory doesn't work yet. Wrong owner. I made /var/mail owned by vmail:vmail but that is not good. Maybe it should be owned by dovecot. Who is the owner of the convert process?
EJ
I think that vmail should be the correct user/group for this but it could be a problem if the source and destination directories are the same (home directory is the same as mail_location).
Have you set a different mail location? I think Dovecot can't rename the old directory if the new mail location is in the same directory.
-- Daniel
The renaming of the maildir fails, wrong user. I can fiddle this out. Perhaps the /var/mail tree should be owned by user dovecot. Dunno, have to try. If all fails, I give the mailbox 777 during the conversion...
There are no /home/<user> mboxes on the old server since the (virtual) users have no home dir. On the new system all mail is owned by vmail. Again the users are virtual and are in MySQL databases (postfix/dovecot/postfixadmin/roundcube).
On the new server all users use Maildir structure in /home/vmail/<domain>/<user>. The old postfix mail is made available on the new server in /var/mail/<user> by copy or nfs to facilitate the conversion of old messages to Maildir. That structure does not work as we know, there must be a directory in between. With some scripting I could make the old mail appear as /var/mail/<user>/inbox on the new server. Doing this makes this approach more ore less the same as a big bang conversion using mb2md.pl with the same (dis?)advantages (user not in control when things happen). We have quite a few dormant users too; would be nice to be able to trace them and kick them of the new server.
Egbert Jan
On Fri, 2010-07-30 at 17:01 +0200, Egbert wrote:
The renaming of the maildir fails, wrong user. I can fiddle this out. Perhaps the /var/mail tree should be owned by user dovecot.
No. It's never dovecot user. It's the mail user uid, as returned by your userdb. http://wiki.dovecot.org/UserIds
Op 30-7-2010 17:32, Timo Sirainen schreef:
On Fri, 2010-07-30 at 17:01 +0200, Egbert wrote:
The renaming of the maildir fails, wrong user. I can fiddle this out. Perhaps the /var/mail tree should be owned by user dovecot.
No. It's never dovecot user. It's the mail user uid, as returned by your userdb. http://wiki.dovecot.org/UserIds
There seems to be a problem then. The UID of vmail is 5000 for all users. The rename failed when the whole /var/mail tree was owned by vmail. The rename is quite essentiial to prevent re-converting the mbox again and again...
Egbert Jan
Instead of using convert plugin, you could run mb2md.pl also as post-login script. Probably easier.. http://wiki.dovecot.org/PostLoginScripting
Op 30-7-2010 21:44, Timo Sirainen schreef:
Instead of using convert plugin, you could run mb2md.pl also as post-login script. Probably easier.. http://wiki.dovecot.org/PostLoginScripting
Thanks for your advice, Timo. Much appreciated. Running a script sounds like a good solution. The script runs as root which might simplifiy things ;-)
Are things like %d, %u, %n also available? I have to build the argument list for mb2md.pl in that script.
Egbert Jan
Op 30-7-2010 21:44, Timo Sirainen schreef:
Instead of using convert plugin, you could run mb2md.pl also as post-login script. Probably easier.. http://wiki.dovecot.org/PostLoginScripting
Indeed this seems to work. Thanks. One problem: The login is denied the first time (user/passw not correct). The /var/mail/<user> IS converted though. Cannot find any hint where to look in the logs... A second attempt logs the user in and the converted messages are displayed as unread.
In dovecot.conf: protocol imap { #mail_executable = /usr/lib/dovecot/imap mail_executable = /home/egbert/script.sh
The script in /home/egbert: #!/bin/sh # # no mbox in homedir, only in /var/mail /home/egbert/mb2md.pl -S -W -s /var/mail/egbert -d $PWD # # make copied messages ownd by vmail chown vmail:vmail $PWD/cur/* # # disable double conversion mv /var/mail/egbert /var/mail/egbert-converted # # continue to run imap exec /usr/lib/dovecot/imap "$@"
$PWD = /home/vmail/vandenbussche.nl/egbert All is hardcoded for testing; I will use suhstrings of $USER to make this more general. Since the script runs as root, it is not very importand how /var/mail ownerships looks like.
Egbert Jan
On Fri, 2010-07-30 at 12:36 +0200, Egbert wrote:
So things finally start to work. Only the rename of the /var/mail/<user> directory doesn't work yet. Wrong owner. I made /var/mail owned by vmail:vmail but that is not good. Maybe it should be owned by dovecot. Who is the owner of the convert process?
Convert plugin wants to rename the mail root directory. It won't work nicely unless you have something like
/var/mail/<user>/mail/
under which all the mailboxes are. Anyway, I'd suggest using http://dovecot.org/tools/mb2md.pl instead of convert plugin. That'll preserve stuff better.
Op 30-7-2010 16:27, Timo Sirainen schreef:
On Fri, 2010-07-30 at 12:36 +0200, Egbert wrote:
So things finally start to work. Only the rename of the /var/mail/<user> directory doesn't work yet. Wrong owner. I made /var/mail owned by vmail:vmail but that is not good. Maybe it should be owned by dovecot. Who is the owner of the convert process?
Convert plugin wants to rename the mail root directory. It won't work nicely unless you have something like
/var/mail/<user>/mail/
under which all the mailboxes are. Anyway, I'd suggest using http://dovecot.org/tools/mb2md.pl instead of convert plugin. That'll preserve stuff better.
Thanks Timo. I did play with mb2md.pl and it does the job. It is more an operational problem, WE do the convert for a few hundred users (they have no mbox in home because they dont have a homedir, just /var/mail/<user>) OR the convert happens when the user logs in on the new server. Both aproaches have they pro and con.
Egbert Jan
participants (3)
-
Daniel Luttermann
-
Egbert
-
Timo Sirainen