As simple as the title goes, this small python script will go through your email, filter emails from the last time it checked them and downloads the attachments in the following pattern:
attachments_for_<username at the email address>
create file named usernamepwd.txt
and add the email and credentials for your users. And run the following command
pip install -r requirements.txt
python main.py <hostname>
<hostname> should be your hostname. Example: mail.thetwl.org, mail.ashimdahal.com, etc.
Format for usernamepwd.txt
[email protected], password123
[email protected], P4$$w0rD
// you can either include or remove spaces between the user-email and password as it's getting stripped nonetheless
Demo Example:
python main.py imap.gmail.com
In order to run the script with gmail do the following steps:
- Activate 2FA in your google account.
- Under the newly activated 2FA, you'll have option to generate application spefcific password.
- Generate an application spefcific password and keep that password in the usernamepwd.txt file.
- Add a better way to share password than plain .txt file.
- Login to office 365 using OAuth2.
- Increase efficienty by not only tracking last date for the attachments saved but also last date for any emails checked.