473,320 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

appending messages in imaplib

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

Dec 5 '05 #1
2 4425
hu*******@gmail.com wrote:
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/~cz21055...s/mbox2imap.py

And there are other entries...

Looking for mh2imap seem quasi unproductive.

A+
Dec 5 '05 #2
>On google the first link is... a Python script.
http://home.tiscali.cz:8080/~cz21055...s/mbox2imap.py And there are other entries...


That appears to contain the magic I need thanks. It just use python
mailbox so adding in MH support should be trivial. Then I need to add
some directory walking logic around it and all should be good.

Just ran a 1500 mail mbox through it and it worked like a charm.

Cheers,
Huw

Dec 5 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bill Sneddon | last post by:
Anyone have an example they are willing to share that shows how to use the store command in imaplib? store( message_set, command, flag_list) Alters flag dispositions for messages in mailbox. ...
0
by: Mr. Magoo | last post by:
I'm working with imaplib. I'm trying to flag (or move or copy - anything that takes a message_set as an argument) a bunch of messages with one command and am having trouble. === def...
1
by: Colin Brown | last post by:
The Python 2.3 documentation in imaplib says: Internaldate2tuple( datestr) Converts an IMAP4 INTERNALDATE string to Coordinated Universal Time. Returns a time module tuple. Time2Internaldate(...
1
by: Raghul | last post by:
Is it posssible to read only the new messages or unread messages using imaplib in python? If it is possible pls specify the module or give a sample code. Thanks in advance
0
by: Wolfgang Kohnen | last post by:
Hello out there! I am new to python and so far I like it a lot. Now I want to create some IMAP mailboxes on my cyrus imapd, with quotas and each user should be subscribed to her/his own spam...
5
by: Antoon Pardon | last post by:
This little program gives IMO a strange result. import imaplib user = "cpapen" cyr = imaplib.IMAP4("imap.vub.ac.be") cyr.login("cyrus", "cOn-A1r") rc, lst = cyr.list('""', "user/%s/*" %...
1
by: csselo | last post by:
Hi I am looking for a code sample which searches mail by date with imaplib example: get email from 01.01.2007 to now how can I change imaplib search parameters?
1
by: aspineux | last post by:
imaplib use exception to report errors, but some problems must be detected by checking the return value ! For example, when trying to append into a mailbox with wrong ACL, imaplib return 'NO',...
0
by: aspineux | last post by:
setacl and getacl look to be already "Cyrus" specific (according the doc), why not to extend imaplib a little bit more ? Here are some code I wrote and tested to support cyrus "expire" that...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.