Package: cs.mailutils
Convenience functions and classes to work with email.
- Cameron Simpsoncs@cskk.id.auLatest release 20210306:
New RFC5322_DATE_TIME with format for datetime.strptime to emit an RFC5322 date-time token.Functionismaildir(path)Test ifpathpoints at a Maildir directory.Functionismbox(path)Open path and check that its first line begins with "From ".Functionismhdir(path)Test ifpathpoints at an MH directory.ClassMaildir(mailbox.Maildir,mailbox.Mailbox)A faster Maildir interface.
Trust os.listdir, don't fsync, etc.MethodMaildir.__getitem__(self, key)Return a mailbox.Message loaded from the message with keykey.
The Message's .pathname property contains .keypath(key),
the pathname to the message file.MethodMaildir.add(self, message, key=None)Add a message to the Maildir.messagemay be an email.message.Message instance or a path to a file.MethodMaildir.as_mbox(self, fp, keys=None)Transcribe the contents of this maildir in UNIX mbox format to the
filefp.
The optional iterablekeysdesignates the messages to transcribe.
The default is to transcribe all messages.MethodMaildir.flush(self)Forget state.MethodMaildir.get_headers(self, key)Return the headers of the specified message asMethodMaildir.get_message(self, key)Return a mailbox.Message loaded from the message with keykey.
The Message's .pathname property contains .keypath(key),
the pathname to the message file.MethodMaildir.iterheaders(self)Yield (key, headers) from the Maildir.MethodMaildir.keypath(self, key)Return the path to the message with maildir keykey.PropertyMaildir.msgmapScan the maildir, return key->message-info mapping.MethodMaildir.newkey(self)Allocate a new key.MethodMaildir.open(self, key, mode='r')Open the file storing the message specified bykey.MethodMaildir.save_file(self, fp, key=None, flags='')Save the contents of the file-like objectfpinto the Maildir.
Return the key for the saved message.MethodMaildir.save_filepath(self, filepath, key=None, nolink=False, flags='')Save the file specified byfilepathinto the Maildir.
By default a hardlink is attempted unlessnolinkis supplied true.
The optionalflagsis a string consisting of flag letters listed at:http://cr.yp.to/proto/maildir.htmlReturn the key for the saved message.MethodMaildir.save_message(self, M, key=None, flags='')Save the contents of the MessageMinto the Maildir.
Return the key for the saved message.Functionmake_maildir(path)Create a new maildir atpath.
The path must not already exist.FunctionMessage(msgfile, headersonly=False)Factory function to accept a file or filename and return an email.message.Message.Functionmessage_addresses(M, header_names)Yield (realname, address) pairs from all the named headers.Functionmodify_header(M, hdr, new_values, always=False)Modify a MessageMto change the value of the named headerhdrto the new valuenew_values(a string or an interable of strings).
Ifnew_valuesis a string subclass, convert to a single element list.
Ifnew_valuesdiffers from the existing value or ifalwaysis true, save the old value as X-Old-hdr.
Return a Boolean indicating whether the headers were modified.Release LogRelease 20210306:
New RFC5322_DATE_TIME with format for datetime.strptime to emit an RFC5322 date-time token.Release 20171231.1:
DISTINFO fix. No semantic changes.Release 20171231:
Update imports, clean some lint. No semantic changes.Release 20160828:Use "install_requires" instead of "requires" in DISTINFO.modify_header: accept multiple header values.Message factory function: open message files with errors="replace" because messages might have any arbitrary guff in them; accept the mangling that may occur.Add new_message_id() and need_message_id().Add message_references() to return related Message-IDs from Reply-To: and References: headers.Python 2/3 portability fixes.Assorted bugfixes and improvements.Release 20150116.2:
Update PyPI metadata.Release 20150116:
Initial PyPI release.