appending messages in imaplib

H

huw.lynes

So I have the unfortunate task of migrating several hundred users from
local mail (mbox and mh) up to an exchange server as part of wearisome
SOX compliance nonsense.

I thought the best path through this thicket would be to knock up a
quick python script using imaplib to replicate folder structures on the
IMAP server and copy the mails accross.

Accessing the IMAP server is great. I can log in, search for mail,
change folder and fetch mail. but I just can't seem to get .append() to
work. Here is a quick example.

server = IMAP4("mail01")
server.login("huw-l","xxxxxxxxx")
('OK', ['LOGIN completed.'])
server.create("Migration")
('OK', ['CREATE completed.'])
#using a mail client I can verify that the folder was created
server.select("Inbox")
'OK'
r,data = server.fetch('220','(RFC822)')
#data now contains a real mail message off the server
message = data
server.append("Migration",None,None,message)

at which point it just sits there and does nothing. Any ideas greatly
appreciated. I'm assuming that it has something to do with the way I'm
passing it the message but I don't really know where to go from here.

Thanks,
Huw
 
L

Laurent Pointal

So I have the unfortunate task of migrating several hundred users from
local mail (mbox and mh) up to an exchange server as part of wearisome
SOX compliance nonsense.

I thought the best path through this thicket would be to knock up a
quick python script using imaplib to replicate folder structures on the
IMAP server and copy the mails accross.

[zip]


Have you tried to search for mbox2imap ?

On google the first link is... a Python script.

http://home.tiscali.cz:8080/~cz210552/distfiles/mbox2imap.py

And there are other entries...



Looking for mh2imap seem quasi unproductive.

A+
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top