A small Python script that posts tweets based on incoming emails. Any unread email with the subject mail2x is processed. The email body becomes the tweet text, and a single attached image (if present) is uploaded and included in the tweet.
requests, requests_oauthlib Edit the script and fill in your Twitter API keys and email IMAP credentials:
API_KEY = '...'
API_SECRET_KEY = '...'
ACCESS_TOKEN = '...'
ACCESS_TOKEN_SECRET = '...'
IMAP_SERVER = '...'
EMAIL_USER = '...'
EMAIL_PASSWORD = '...'
Install dependencies:
pip install requests requests_oauthlib
Make the script executable and run it:
chmod +x mail2x.py
python3 mail2x.py
To automate the script, add an entry to crontab. For example, to run it at five minutes-past every hour:
5 */1 * * * /usr/bin/python3 /path/to/mail2x.py
mail2x are processed. This project is made available under a GPL3 licence -- see COPYING for the full text.