For a project I'm trying to take a photo using a camera connected to my raspberry pi after pressing a button and then sending the photo taken using Gmail.
So far, all I've figured out is how to take the photo after pressing the button (see the code), but I still haven't figured out how to send an email with the photo after taking the photo. By the way, I want the photo being taken and the email being sent done in only one button press. Also, I'm using IDLE python 3.
from gpiozero import Button
from picamera import PiCamera
from signal import pause
import time
camera = PiCamera()
def take_picture_with_camera():
image_path = 'blahblah.jpg'
camera.capture(image_path)
print('Took photo')
button = Button(4)
button.when_pressed = take_picture_with_camera
pause()