Just a simple script that runs on a Raspberry Pi that allows an email to go out on a button push.
- Python 3
- pip
- sparkpost:
pip install sparkpost - requests:
pip install requests(should be installed with sparkpost) - Raspberry Pi with IO Port 16 connected to a button
- Setup a SparkPost account and create an API Key for the account.
- Setup the environment variables below.
- Set them up under
/etc/environmentlike below. - All are required to run
- Set them up under
SPARKPOST_API_KEY=longapikey
BTNPI_FROM_ADDRESS="email@example.com"
BTNPI_TO_ADDRESS="email@example.com"
BTNPI_TO_ANNOUNCE="email@example.com"
BTNPI_SUBJECT="Subject Line"
BTNPI_MESSAGE="Hello, the mailbox button was pressed."
SPARKPOST_API_KEYenvironment variable for SparkPost to send messagesBTNPI_FROM_ADDRESSaddress that the Pi sends out ofBTNPI_TO_ADDRESSaddress that the Pi sends to when the button is pushedBTNPI_TO_ANNOUNCEwhen the Pi turns on it will email the External IP to this addressBTNPI_SUBJECTsubject line in the emailBTNPI_MESSAGEmessage to send when the button is pressed
Note: All of these might be best in a JSON file - feel free to submit a PR :)
These are the instructions to run the program continually on a Raspberry Pi.
- Update
/etc/rc.localto have(sleep 30;python /button.py)&
The python script will output it's status and button presses to the screen