auino / mail-attachments-archiver

Store mail attachments to file-system
14 stars 7 forks source link

mail-attachments-archiver

Store mail attachments to file-system

Description

This program is a simple mail client written in Python. It allows you to automatically archive email attachments in function of predefined rules.

Installation

Clone the repository:

git clone https://github.com/auino/mail-attachments-archiver.git

Configuration

Edit the mail-attachments-archiver.py file content by configuring the program and customizing its behavior.

IMAP connection setup

Following variables are used and should be configured:

Behavior configuration

The behavior of the program is configured by associating specific senders to specific subjects keywords. When the program finds an email matching the couple (sender, subject), the attachment is stored on the disk. It is possible to set up a list of senders associated to a list of subjects.

You can configure a separated list of senders (as in mail-attachments-archiver.py, for YOUR_MAIL, ALICE_MAIL and BOB_MAIL parameters, for reuse them), but it is not strictly necessary.

The most important part of the behavior settings is relative to the MAIL_MAPPINGS variable content. Such variable contains a list of rules objects, defined for instance as follows:

{
    'filter_sender': True,
    'senders': [ 'me@gmail.com', 'you@gmail.com' ],
    'add_date': True,
    'subject': [ 'GITHUB TEST', 'GITHUB-TEST', 'GITHUBTEST' ],
    'destination': '/media/disk/test/'
}

The following attributes are needed:

Source address and subject checks are both case insensitive. Concerning subject check, if the specified subject is found inside of the entire object (not equality comparison), the attachment is store, otherwise not.

Additional settings

Additional settings may be configured in order to define emails management.

Notes

This program is an extended and customized version of a code snipped found on Stack Overflow.

Supporters

Contacts

You can find me on Twitter as @auino.