Moving Email


Be careful, especially if moving from mail.cs. I tried the command as listed below, and it assumed EVERYTHING in the file system of my home directory was a mail folder.

So, I ended up with Testing/.login Testing/.ssh/ etc, etc until it finally alerted on a bad name, and I could Ctrl C out of it.

Moving email to Exchange

Here are some notes sent to me from Giles Malet in IST:

Subject:    Fwd: Transferring mail to Exchange
Hi Lawrence,,

Here's an e-mail, minus the attachment, that I sent to Keith McGowan,
when he was doing similar things. I used the `root' accounts in this
case, but otherwise it's similar.

So, if your user is `fred', I'd try a command such as this (replace
artsservices with your server name) on some xhier Solaris box:

$ mailutil transfer -m suffix=-Dup -v \

Hopefully you can test & play around a bit before stepping up to the
line! Please call if you need more info.


-------- Original Message --------
Subject: Transferring mail from cyrus to Exchange
Date: Wed, 02 Dec 2009 13:59:45 -0500
From: Giles Malet 
To: Keith C McGowan 

Hi Keith,

The command I use to do it is something like this:

$ mailutil transfer -m suffix=-Dup -v \

This works from a Linux box, and will ask for the source & dest passords
in turn. The mailutil in xhier imap2006 will work too: it can read the
password from a file, but it would use the same password in each case.

The -m tries to work around the stupidity of this command: you can't get
it to create folders that don't exist, and just merge into ones that do.
It has to distinguish between those two cases, and requires separate
invocations to deal with them: the creating new, hopefully non-existent,
folders is a compromise.

The last two fields are source and destination mailboxes. So I auth'd as
your cyrus to get the mail, and as a special service account on Exchange
to put it in place, although auth'ing as the user, and using their
password is another option.

I test by using a destination such as:


.... so then all the mail is put under a sub-tree on my account, which I
can delete if it worked.

Anyhow, we should be able to do something similar if we need to move
students. You could use it to move others to connect too, although I'm
happy to get involved.

I attached the output from the above for the friedman import (use -d -v
to get copious output). I ran the following on it to produce a more
readable report:

$ grep '^{.*=>' /tmp/friedman.dbg | sed -e s'/{[^}]*}//g'



Using mailutil on cscf.cs for our accounts (dump of notes from ST#66259)

@cscf[104]% which mailutil


@cscf[105]% mailutil -v
mailutil version 2007b.13

usage: mailutil command [switches] arguments

Standard switches valid with any command:
        [-d[ebug]] [-v[erbose]] [-u[ser] userid] [--]

 check [MAILBOX]
   ;; report number of messages and new messages
 create MAILBOX
   ;; create new mailbox
 delete MAILBOX
   ;; delete existing mailbox
   ;; rename mailbox to a new name
 copy [-rw[copy]] [-kw[copy]] [-ig[nore]] SOURCE DESTINATION
 move [-rw[copy]] [-kw[copy]] [-ig[nore]] SOURCE DESTINATION
   ;; create new mailbox and copy/move messages
 append [-rw[copy]] [-kw[copy]] [-ig[nore]] SOURCE DESTINATION
 appenddelete [-rw[copy]] [-kw[copy]] [-ig[nore]] SOURCE DESTINATION
   ;; copy/move messages to existing mailbox
 prune mailbox SEARCH_CRITERIA
   ;; prune mailbox of messages matching criteria
 transfer [-rw[copy]] [-kw[copy]] [-ig[nore]] [-m[erge] m] SOURCE DEST
   ;; copy source hierarchy to destination
   ;;  -merge modes are prompt, append, or suffix=xxxx

From the man page:
     mailutil transfer copies an entire hierarchy of mailboxes
     from the named source to the named destination.  Mailboxes
     are created on the destination as needed.  Any error in
     copying messages will cause the transfer to stop. 

In the following, I'm going to try copying my "Vendors" mailbox from my maildir account to my Connect account:

$ mailutil transfer -m suffix=-Dup -v \\



Let's see if that works:

@cscf[107]% mailutil transfer -m suffix=-Dup -v \\



[Trying IP address []]
{} password: *enter maildir password*

[Trying IP address []]
[The Microsoft Exchange IMAP4 service is ready.]
warning: Kerberos error: No credentials cache found (try running kinit) for
[Retrying using PLAIN authentication after The AUTH protocol exchange was canceled by the client.]
{} password: ***enter ADS password ***
Listing mailboxes...
Copying {"lfolland"}Vendors/SGI
  => {"lfolland"}Testing/Vendors/SGI
[Reusing connection to"lfolland"]
[[UNSEEN 37] First unseen.]
[CREATE completed.]
{"lfolland"}Vendors/SGI [76 message(s)] => {"lfolland"}Testing/Vendors/SGI
warning: Keywords are not supported!
... repeated a total of 76 times ...
warning: Keywords are not supported!
[Ok 76 messages(s)]
[Logging out]
[Microsoft Exchange Server 2007 IMAP4 server signing off.] 

After it was done, I checked both accounts.  The original (maildir) account was untouched - so it is a copy.  The Connect account did not display the new mailbox until I subscribed to it.  Once I did that (and all the subfolders) everything was there with the original status (read/unread) and dates.

So it looks good! 

Example copying email from maildir to Exchange account

Here is the script I setup for Tamer to transfer all of his mail on maildir to a mailbox called "Temporary" on Connect:
(root)[337]% cat copymail
mailutil transfer -m suffix=-Dup -v '{}' '{}Temporary/' 

An alternate copy uses ImapSync as described in MaildirToConnect

Example copying a folder from mail.cs to maildir.cs

Copying the mail folder "Vendors" which is in the "mail" directory on mail.cs to a folder called "Temporary" on maildir.cs. User is "lfolland" in both cases.

Note that you will be prompted for lfolland's password for both servers

@cscf[108]% cat
mailutil transfer -m suffix=-Dup -v '{}mail/Vendors' '{}Temporary/' 

Example copying all of a user's email from mail.cs to maildir.cs

In the example below, we are copying all of the email for "lfolland" from mail.cs to the folder "oldmail" on "maildir.cs" (all of the mail will still be on mail.cs. They will need to delete it manually when they're ready)

Note that you will be prompted for lfolland's password for both servers

@cscf[108]% cat
mailutil transfer -m suffix=-Dup -v '{}' '{}oldmail/'
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r6 - 2012-09-06 - BillInce
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback