MAILPROCESSING(1)
π MAILPROCESSING(1) β the mailprocessing rc file, explained by your bestie
okay so welcome to the mailprocessing manpage, aka the docs for the config files ~/.mailprocessing/imap.rc and ~/.mailprocessing/maildir.rc β the filter configuration for mailprocessing. it's in the User Commands section of the manual, and bestie, it's giving power. π¦
β¨ SYNOPSIS β¨
processor.maildir_base = '/home/user/Maildir'
for mail in processor:
pass
πΈ DESCRIPTION πΈ
okay so here's the tea, and it's actually the most important thing on this whole page: the rc file for maildirproc and imapproc is not a set of declarative rules. not even a little. it's literally just a simple Python program. π
that program gets access to a "maildir processor" object, and that object produces mail objects. your entire mail processing logic is just if/elif/else statements, and you do stuff by calling methods on the mail objects. that's it. that's the whole vibe. no cap. β¨
maildir-specific and IMAP-specific functionality is implemented by the MaildirProcessor and ImapProcessor classes, respecitively.
π The MailProcessor class
iterating over a MailProcessor instance yields Mail instances. imapproc and maildirproc will create a MailProcessor instance for you, and it's available as the global processor variable in the rc file's name space. so you never have to construct it yourself. slay. π«Ά
π Readable and writable properties
auto_reload_rcfileβ whether the rc file should be automatically reloaded when it has been modified. assigning to this property overrides the corresponding command-line option.maildir_baseβ the base directory of maildirs. assigning to this property overrides the corresponding command-line option. this property is specific toMaildirProcessorinstances.maildirsβ a list of maildirs (subdirectories of the maildir base directory). assigning to this property overrides the corresponding command-line option. this property is specific toMaildirProcessorinstances.foldersβ a list of IMAP folders. assigning to this property overrides the corresponding command-line option. this property is specific toImapProcessorinstances.
π§ Methods
create_folder(folder, parents=True, prefix='.')β creates folder folder (a string, or a list of namespace components). it is totally safe to call this for folders that already exist: if the folder is already there, the method logs that it exists and exits without trying to create it. forMaildirProcessor, folder does not need to be on the same file system as the mail. if the folder path is relative, it gets treated as relative to the maildir base directory. the boolean keyword argument parents decides whether parent folders get created too β like, if you create'github.jrosdahl.maildirproc', then'github'and'github.jrosdahl'get created as well. that's the default behaviour, bestie. the prefix keyword argument is a prefix to prepend the folder name with; it defaults to the processor'sprefixattribute, which gets set via the--prefixcommand line attribute forMaildirProcessorinstances. π
π Writable properties
logfileβ location of the log file. assigning to this property overrides the corresponding command-line option.
π The Mail class
indexing a Mail instance with a header name (a string) returns a Header instance. example time:
for mail in processor:
myheader = mail['From']
π Readable properties
folderβ the IMAP folder in which the mail is situated. only applicable forImapProcessor.maildirβ the maildir in which the mail is situated. only applicable forMaildirProcessor.pathβ full filesystem path to the mail. only applicable forMaildirProcessor.targetβ aTargetinstance.
π¦ Methods
copy(maildir, create=False)β copy the mail to maildir (a string). maildir does not need to be on the same file system as the mail. if the maildir path is relative, it gets treated as relative to the maildir base directory. if you set the optional create keyword argument toTrue, the folder (and its parent folders) will be created if it doesn't exist. by default, non-existent folders are not created.delete()β delete the mail. bye bestie. πforward(addresses[, env_sender])β forward the mail to one or several e-mail addresses and delete the mail. addresses can be either a string or a list of strings. env_sender (optional) specifies which envelope sender address to use.forward_copy(addresses[, env_sender])β forward a copy of the mail to one or several e-mail addresses. addresses can be either a string or a list of strings. env_sender (optional) specifies which envelope sender address to use.from_mailing_list(list)β check whether the mail originated from the mailing list list (a string). currently, the headersDelivered-To,Mailing-List,X-BeenThereandX-Mailing-Listare checked. returns a boolean.strict_mailing_list(list)β check whether the mail originated from the mailing list list (a string). it's a bit stricter thanfrom_mailing_list()and only matches the content of typical mailing list headers, namelyList-Archive,List-Help,List-ID,List-Post,List-SubscribeandX-Mailing-List.is_seen()β returnsTrueif the message has been seen by the user,Falseotherwise.is_flagged()β returnsTrueif the message has been flagged by the user,Falseotherwise.move(maildir, create=False)β move the mail to maildir (a string). maildir must be on the same file system as the mail β otherwise nothing will happen and an error will be logged. forMaildirProcessor, a relative maildir path gets treated as relative to the maildir base directory. if you set the optional create keyword argument toTrue, the folder (and its parent folders) will be created if it doesn't exist. by default, non-existent folders are not created.
π¨ not me warning you about move(): if it's not the same file system, it's a no-op plus a log line. plan accordingly, bestie.
π The Header class
π Methods
contains(case-insensitive-string)β check whether case-insensitive-string is part of the header. returns a boolean.matches(case-insensitive-regexp)β check whether case-insensitive-regexp (with an implicit.*prefix) matches the header. returns a boolean.
π The Target class
π Methods
contains(case-insensitive-string)β check whether case-insensitive-string is part of theToorCcheader. returns a boolean.matches(case-insensitive-regexp)β check whether case-insensitive-regexp (with an implicit.*prefix) matches theToorCcheader. returns a boolean.
π₯ EXAMPLES π₯
for some examples, see the examples directory. go peek, it's worth it, fr fr. π
π«Ά SEE ALSO π«Ά
imapproc(1), maildirproc(1) β your other besties, go say hi. πΈ
and that's the whole page, bestie!! this one lives in the User Commands section of the manual, and this version of it is dated to match the mailprocessing page as shipped β so like, that's the source and the date, folded into this little sign-off instead of a boring footer line. mwah. π
β¨ππ¦
π¦ where this page comes from
- fedora 43: mailprocessing 1.2.7-14.fc43 Β· GPL-2.0-only
- fedora 44: mailprocessing 1.2.7-15.fc44 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms