[Tutor] Invalid syntax issue
Kody Fergerson
rider.kody at gmail.com
Mon Nov 3 00:55:50 CET 2014
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.wasson at gmail.com
GMAIL_USER = kody.wasson at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141102/7593fb4b/attachment.html>
More information about the Tutor
mailing list