My project consists of one RPi 3 with motion sensor and camera attached. All this is linked to my gmail account. Once motion is detected, it will take a recording and email me saying that motion has been detected and it should also attach the image. All this happens automatically. I have ssmtp all set up for my gmail and everything works perfect, apart from the image is not attached to the email. So, I get the notification, but with no image attached. Please help. Please see my script below and please advice as I am stuck.
import RPi.GPIO as GPIO
AuthUser = 'email@example.com
AuthPass = 'mypassword'
toAdd = 'firstname.lastname@example.org
fromAdd = AuthUser
subject = 'Motion Detected'
mail = smtplib.SMTP('smtp.gmail.com',587)
gmailUpload = ()
mail.send_mail = (fromAdd, toAdd)
sensorPin = 7
GPIO.setup(sensorPin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
prevState = False
currState = False
camera = picamera.PiCamera()
prevState = currState
currState = GPIO.input(sensorPin)
if currState != prevState:
newState = "HIGH" if currState else "LOW"
print ("GPIO pin %s is %s" % (sensorPin, newState))
fileName = getFileName()
print ("Starting Recording...")
print ("Stopped Recording")
print ("Sending Mail Notification...")
subprocess.call("mail -s 'Motion Detected' email@example.com
< /home/pi/mail/images", shell=True)