Hello, I am trying to use a code from Adafruit to have Python send an email when triggered by my Arduino. I'm a novice to programming so it"s somewhat hard for me. I used the code copied verbaticm only changing my email and password, the email in there is a temporary one so I'm not worried about you all having it. When I try to check it or run it it comes up with "invalid syntax" and highlights the first "@" symbol. The code is as follows...
import time import serial import smtplib TO = kody.was...@gmail.com GMAIL_USER = kody.was...@gmail.com GMAIL_PASS = shed no tears SUBJECT = 'Intrusion!!' TEXT = 'Your PIR sensor detected movement' ser = serial.Serial('COM4', 9600) def send_email(): print("Sending Email") smtpserver = smtplib.SMTP("smtp.gmail.com",587) smtpserver.ehlo() smtpserver.starttls() smtpserver.ehlo smtpserver.login(GMAIL_USER, GMAIL_PASS) header = 'To:' + TO + '\n' + 'From: ' + GMAIL_USER header = header + '\n' + 'Subject:' + SUBJECT + '\n' print header msg = header + '\n' + TEXT + ' \n\n' smtpserver.sendmail(GMAIL_USER, TO, msg) smtpserver.close() while True: message = ser.readline() print(message) if message[0] == 'M' : send_email( time.sleep(0.5) I greatly appreciate you assistance in this matter. Thank you, Kody.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor