Sending An Email With Attached Photo Using Python And The Raspberry Pi
We have already covered using a Raspberry Pi and Python to send an email containing basic text – but what if you wanted to attach a picture instead? In this tutorial we are going to adapt our code from our basic email tutorial to allow picture attachments to be sent. We will use a Raspberry Pi Camera to capture an image and send the photo out as soon as the button is pressed. Going forwards, this code chunk could be adapted to send when your cookie alarm is tripped, at a specific time of day, or whatever other condition you come up with!
There are a lot of different operating systems out there for the Raspberry Pi, so we are going to focus on the most popular: Raspbian. We are using the version dated: 2019-7-10 (Pi 4 Compatible) available from the Raspberry Pi Foundations’ Download Page. You don’t need to use the Raspberry Pi 4, any Raspberry Pi will do. However, deviating from the recommended operating system version may result in different / additional steps so if you are very new to this, we recommend following the tutorial exactly.
If you have any questions, or need further clarification please post in the comments section below; this way future users of this tutorial can see the questions and answers!