To copy messages from different sources you need to have at least two storage objects.

Those storage objects include:

Each of those objects have a iter_messages and a append_messages method.

>>> from pymailmove.imap import IMAPServer
>>> from pymailmove.mbox import MboxStorage
>>> src = IMAPServer('localhost')
>>> dst = MboxStorage('backup.mbox')
>>> for msg in src.iter_messages():
>>>   dst.append_message(msg)

Server object’s iter_messages and append_message methods may have a mailbox parameter.

>>> src = IMAPServer('localhost')
>>> dst = MboxStorage('remotehost')
>>> for msg in src.iter_messages(mailbox='submailbox'):
>>>   dst.append_message(msg, mailbox='submailbox')


pymailmove.message Module

Message object


Message(raw[, date, flags]) Represents a message

Class Inheritance Diagram

Inheritance diagram of pymailmove.message.Message

pymailmove.imap Module

IMAP Storage


IMAPServer(host[, port, login, ssl]) This class represents a mailserver

Class Inheritance Diagram

Inheritance diagram of pymailmove.imap.IMAPServer

pymailmove.mbox Module

mbox storage


MboxStorage(path) This class represents a mbox file

Class Inheritance Diagram

Inheritance diagram of pymailmove.mbox.MboxStorage