All,

Here is my solution to my original post (when i accidently assumed the alias CYRUS 
LIST :)

I have since used the UW mail tools (imap-utils.tar.Z), which does need you to have 
the c-client source from the UW IMAP server (imap-2000c.tar.Z), compiled but not 
installed. These are from ftp://ftp.cac.washington.edu/imap/ . I have a slightly 
modified the imapxfer program to take username/password for source and dest IMAP 
servers on the command line:

usage: ./imapxfer "{source_host}prefix" "souce_username" "source_passwd" 
"{destination_host}prefix" "dest_username" "dest_passwd

The "{host}prefix" syntax is from the UW c-client.

The only problem I have noticed, is that it opens the source IMAP server as READ-ONLY, 
but then tries to set the /SEEN flag on retrieval of the message, and thus generates a 
permission denied message on STDERR.  All flags get copied across fine.  This program 
also has the advantage over the stalker.com tool (MoveIMAPMail), in that it will copy 
the contents of a folder when the folder already exists on the dest host.

The patch is below.


At 04:52 PM 9/5/2001, Nick Sayer wrote:
>CYRUS LIST wrote:
>
>>Has anyone done a script to migrate folder and mail data from a foreign IMAP
>>sever?
>>Basically, I need to automate the procedure of a client logging into both
>>old and new IMAP servers, and for each folder, create the folder, and for
>>each message, copy the message, recursively through the entire account.
>>Auth information would be known for both sides, but may not be the same.
>>Kind regards,  Stuart.
>
>While not perhaps exactly what you want, I was able to pretty quickly cobble together 
>a pair of scripts in Perl using the Mail::IMAPClient module to go from IMAP folders 
>to and from the mbox format. Among the nice things about this module is the fact that 
>even though they didn't specifically code handling for ACL and Quota stuff, you can 
>simply do an $imap->GETACL("user","flags"...); call -- the all-caps functions 
>automatically get converted into matching statements to the imap server.
>
>I would post my scripts, but they're not very good -- My perl-fu is weak and the 
>scripts don't do things like check for invalid headers, NULs in the messages, etc. 
>I'm sure a real Perl hacker has already done much better. :-)



NOTE:  Dont forget to adjust the Makefile to point to your compiled c-client dir: 
../imap-2000c/c-client

--- imapxfer.c.old      Tue May 29 10:55:59 2001
+++ imapxfer.c  Tue May 29 11:04:28 2001
@@ -46,6 +46,7 @@
 int ddelim = -1;               /* destination delimiter */
 FILE *f = NIL;
 
+char user[MAILTMPLEN],pass[MAILTMPLEN];
 
 /* Function prototypes */
 
@@ -149,16 +150,19 @@
   MAILSTREAM *stream;
 #include "linkage.c"
                                /* validate arguments */
-  if ((argc != 3) || (argv[1][0] != '{') || !(sp = strchr (argv[1],'}')) ||
-      (argv[2][0] != '{') || !(dp = strchr (argv[2],'}')))
-    printf ("usage: %s \"{source_host}prefix\" \"{destination_host}prefix\"\n",
-           argv[0]);
+  if ((argc != 7) || (argv[1][0] != '{') || !(sp = strchr (argv[1],'}')) ||
+      (argv[4][0] != '{') || !(dp = strchr (argv[4],'}')))
+    printf ("usage: %s \"{source_host}prefix\" \"souce_username\" \"source_passwd\" 
+\"{destination_host}prefix\" \"dest_username\" \"dest_passwd\n", argv[0]);
+  else if ( (! strcpy (user,argv[2])) || (! strcpy (pass,argv[3])) )
+         printf ("?Error copying source user/pass info to memory\n");
                                /* open source mailbox */
   else if (!(ap.stream = mail_open (NIL,argv[1],OP_HALFOPEN)))
     printf ("?Can't contact source server: %s\n",argv[1]);
+  else if ( (! strcpy (user,argv[5])) || (! strcpy (pass,argv[6])) )
+                   printf ("?Error copying destination user/pass info to memory\n");
                                /* open destination server */
-  else if (!(stream = mail_open (NIL,argv[2],OP_HALFOPEN))) {
-    printf ("?Can't contact destination server %s\n",argv[2]);
+  else if (!(stream = mail_open (NIL,argv[4],OP_HALFOPEN))) {
+    printf ("?Can't contact destination server %s\n",argv[4]);
     mail_close (ap.stream);
   }
   else if (!(f = tmpfile ())) {        /* open temporary file */
@@ -387,11 +391,11 @@
   switch (errflg) {  
   case BYE:
   case NIL:                    /* no error */
-    fprintf (stderr,"[%s]\n",string);
+//    fprintf (stderr,"[%s]\n",string);
     break;
   case PARSE:                  /* parsing problem */
   case WARN:                   /* warning */
-    fprintf (stderr,"%%%s\n",string);
+//    fprintf (stderr,"%%%s\n",string);
     break;
   case ERROR:                  /* error */
   default:
@@ -419,12 +423,8 @@
 
 void mm_login (NETMBX *mb,char *username,char *password,long trial)
 {
-  if (*mb->user) strcpy (username,mb->user);
-  else {
-    printf ("{%s/%s} username: ",mb->host,mb->service);
-    gets (username);
-  }
-  strcpy (password,getpass ("password: "));
+  strcpy (username, user);
+  strcpy (password, pass);
 }
 
 
#end - copy to before this line


Kind regards,  Stuart.


  

Reply via email to