Puts an email to twitter with a link to the attached file, which will be stored locally
Python Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Compose a Tweet from Mail

TweetFile is a pyton script for installation on your mail-enabled server.
When it receives a eMail, then subject line is transformed into a twitter message.
When the mail contains an attachment it is stored in the file system and a link is
attached to the twitter message.  
The content of the twitter message is also send per Mail to other reciptients.

Authorised users are only identified by their from address. Therefore select an
mail receiver adress which cannot be guessed.


You just need to call the program from the ~/.forward file
for the respective user which should deal with your mail requests.

Content of ~/.forward file:
 |"cd /home/<username>/tweetfile; TMP=/home/<username>/tweetfile/tmp FAKECHROOT_EXCLUDE_PATH=/dev:/usr/lib/python2.6:/usr/bin:/usr/share/perl:/usr/share/perl5:/usr/lib/perl:/home/<username>/tweetfile/tmp fakechroot ./watcher_report_output.sh 2>&1 >> watcher_report_output.log"

 /dev is required for SSL authentication, otherwise urllib2 fails with obscure error  
 /usr/bin and *perl* is required for exiftool  
 /home/<username>/tweetfile/tmp is required because twitter+tempfile creates temporary directories

If you don't like the fakechroot'ing you can comment off the block
"Go into CHROOT" in tweetfile.py

The script watcher_report_output.sh checks the execution of
tweetfile and generate an error mail in case of encountered errors.
In this case further execution of the program is prevented.
When you don't want to use this script then just remove it from the call.

To have some simple logfile rotation for watcher_report_output.sh
use the following crontab entry for the user (again adapt settings).
# Crontab-Entry for simple log archiving
# tweetfile: Simple Logfile cleaner: Every 2 weeks make one backup
24           2       11,21    *     *      cd $HOME/tweetfile; nice bzip2 -c watcher_report_output.log > watcher_report_output.log.bak.bz2 ; rm watcher_report_output.log


- Copy the file tweetfileaccess-template.py to tweetfileaccess.py
- Adapt the settings in tweetfileaccess.py
- Update UserList or add new user in tweetfileaccess.py
  - Twitter Configuration
    - Register tweetfile as a new app to your account
      - Login to
      - Name: tweetfile-<your account name>
      - Description: Tweet text and pictures via eMail
      - Website: https://github.com/sd2k9/tweetfile
      - Get Consumer key and Consumer secret from the next page
      - Go to settings, change Access to Read and Write
      - Create access token via button "Create my access token"
      	(must be done after previous step)
      	- Find them on the OAuth tool tab
- Hide from other users with the command
  chmod og-rw tweetfileaccess.py

License & Author
GNU General Public License, version 2
Copyright (C) 2010 Robert Lange <sd2k9@sethdepot.org>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.


Web Links