This extension for efind provides functions to filter emails. It can read messages from plain text and mailbox files. This makes it possible to search emails stored in a Maildir folder, for example.
Date strings have to be in the format "yyyy-MM-dd HH:mm:ss". The accuracy depends on the number of specified fields. Any field (expect the year) is optional.
Tests if the header key of at least one found message contains the string value. The string comparison is case insensitive.
$ efind . 'mail_check_header("X-Original-To", "john.doe@example.org")'
Tests if the header key is set in at least one found message.
$ efind . 'mail_has_header("X-Virus-Scanned")'
Tests if the body of at least one found message contains text.
$ efind . 'mail_contains("foobar")'
Tests if a filename containing name is attached to a at least one found message. The string comparison is case insensitive.
$ efind . 'mail_find_attachment("invoice.pdf")'
Tests if at least one file is attached to a found message.
$ efind . 'mail_has_attachment()'
Converts the header key to date and compares it to date.
$ efind . 'mail_date_equals("Date", "2017-07-11 18:11:40")'
Tests if the date found in the header key is greater than date.
$ efind . 'mail_date_before("Date", "2017-07")'
Tests if date is greater than the date found in the header key.
$ efind . 'mail_date_after("Date", "2017-07-01 11:39")'
Tests if the sender of a found message contains sender. The string comparison is case insensitive.
$ efind . 'mail_from("Alice") or mail_from("Bob")'
Tests if the receiver of a found message contains receiver. The string comparison is case insensitive.
$ efind . 'mail_from("Bob") and mail_to("Alice")'
Tests if the subject of a found message contains subject. The string comparison is case insensitive.
$ efind . 'mail_from("@acme.org") and mail_subject("invoice")'
Tests if at least one found message has been sent on date.
$ efind . 'mail_sent("2017")
Tests if at least one found message has been sent before date.
$ efind . 'mail_sent_before("2017-01-01")
Tests if at least one found message has been sent after date.
$ efind . 'mail_sent_after("2017-01-01 10:36")
Copy the Python script to ~/.efind/extensions or run the install.sh shell script.