Skip to content
Email and Tweet at boot
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Use this repository to send email and a tweet when a Raspberry Pi boots. This is useful for general debugging and when your IP might change. You can also use this repository to send an email or tweet from the command line.


# if you don't already have git
sudo apt-get install git

# clone the main PiE repository
git clone

To send tweets

To send tweets you must have a normal twitter account and than apply for a twitter development account. See the twitter apps page at to apply for a development account. Once you have a development account you need to create an app and then you can access your developer keys allowing you to send tweets.

The code uses tweepy

# install pip3 if needed
sudo apt-get install python3-pip --yes

pip3 install tweepy

To send email

You can create an email account with gmail for this purpose. It is not the best idea to use your primary email account as the password is stored as plain text and you will need to reduce the security on this account.

Reduce the security on the new gmail account

  • Upper right of gmail click on ‘my account’
  • Select ‘sign-in & security’
  • In the ‘Apps with account access’ section, turn on ‘Allow less secure apps’


Create a file and fill in some parameters. This file is read by both and

pico ~/startupnotify/

Copy and paste the following into the file. When using pico you need to move the cursor with arrow keys. Pico will respond to paste by pasting text at the cursor location. Use ctrl+x to save the file and exit pico.

# tweet
hash_tag = '#my_hash_tag'
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''

# email
# Change to your own account information to send from
gmail_user = ''
gmail_password = 'sender_password'

# list of email accounts to send to
gmail_to = ['']


cd ~/startupnotify
python3 'my test email worked'
python3 'my test tweet worked'

To tweet and email at boot

Use crontab -e and append these lines to your crontab file.

At a command prompt

crontab -e

Select pico editor and paste the efollowing at the end of the file.

@reboot (sleep 10; /usr/bin/python3 /home/pi/startupnotify/ booted)
@reboot (sleep 10; /usr/bin/python3 /home/pi/startupnotify/ booted)

Quit pico editor with keyboard ctrl+x

You can’t perform that action at this time.