importing mail from sendmail system

6 posts / 0 new
Last post
#1 Wed, 05/27/2009 - 17:55
jahlewis

importing mail from sendmail system

I can't find any mention of this in the docs/forums, so here goes:

I'm looking to migrate a number of accounts from a sendmail/dovecot system to virtualmin.

On the source system, new mail is stored in /var/spool/mail/accountname, and saved mail is stored in /home/accountname/mail with files like Drafts, saved-messages, sent-mail etc. I don't know what format these files are in (mbox?)

What is the best way to get this imported to the new account in virtualmin? Is there a script you can run? Something along these lines: http://wiki.dovecot.org/Migration/MailFormat

Thanks.

Wed, 05/27/2009 - 18:53
andreychek

Well, the short (and incomplete) answer is that:

1. A default Virtualmin system uses maildir.

2. Email is stored in the users home directory in /home/$VIRTUAL_SERVER_OWNER/Maildir and /home/$VIRTUAL_SERVER_OWNER/homes/EMAIL_USERNAME/Maildir

3. Your current system is likely mbox, as you suspected (mbox uses a large file for all emails, maildir uses one file per email)

I could have sworn that I've seen some info in the forums or bug tracker on converting from one to the other, but I'm not seeing it ATM.

But hopefully the above helps you get started :-)
-Eric

Wed, 05/27/2009 - 23:28 (Reply to #2)
Joe
Joe's picture

Jamie added a command for this a while back, so you can use something like:

virtualmin copy-mailbox --source /var/spool/mail/USER --dest ~USER/Maildir/

Where USER is the username. You can explicitly give the full path, instead, if you prefer.

--

Check out the forum guidelines!

Fri, 05/29/2009 - 15:28 (Reply to #3)
jahlewis

Awesome, looking forward to trying this out. Forgive the newbie question, but do I need to run this command from anywhere specific? In what context? root?

Fri, 05/29/2009 - 18:32 (Reply to #4)
Joe
Joe's picture

root is the only user that has access to the virtualmin command (for now, though there are plans for future integration of full Webmin ACL support into the command line tools).

It can be run from anywhere, as you're passing in the only two paths that matter (the location of the mbox and the destination Maildir).

--

Check out the forum guidelines!

Tue, 06/09/2009 - 14:55 (Reply to #5)
jahlewis

The script works great when run from the command line. It will even create a Maildir directory if one does not exist. However, I'm running into problems running it from a bash script as root. Here's the script:

#!/bin/bash
# take input from script execution
CLIENT=$1
# convert avenue spoolfile to dovecot format
virtualmin copy-mailbox --source /home/$CLIENT/tmp/$CLIENT-spool --dest ~$CLIENT/Maildir/
chown -R $CLIENT:$CLIENT /home/$CLIENT/Maildir

If I run ./script.sh aagg &> stderr_and_stdout.txt

I get the following in stderr_and_stdout.txt:

Error: Write failed : No such file or directory
Error
-----
Write failed : No such file or directory
-----
Copying 82 messages totalling 3.55 MB ...
chown: cannot access `/home/aagg/Maildir': No such file or directory
done

It appears to be failing while trying to create a Maildir directory, and putting the converted files into it.

What am I doing wrong here? Is this me, or the virtualmin copy-mailbox command?

Topic locked