Hardware Reference
In-Depth Information
Listing 13-8 continued
msg.attach(part)
#enter the SMTP server URL or IP Address between the quotes
s = smtplib.SMTP_SSL(“”, 465)
s.login(smtp_user,smtp_pass)
s.sendmail(msg['From'], msg['To'], msg.as_string())
s.quit()
def sendreport():
msgtext = “This is a sensor status report for “ +;
strftime(“%Y-%m-%d %H:%M:%S”, gmtime()) + “\n”
if GPIO.input(13) == True:
msgtext = msgtext + “Status of door switch is :;
Door open\n”
else:
msgtext = msgtext + “Status of door switch is :;
Door closed\n”
if GPIO.input(15) == True:
msgtext = msgtext + “Status of motion detector ;
is : No motion\n”
else:
msgtext = msgtext + “Status of motion detector ;
is : Motion detected\n”
# Use the GetTemperature routine we
# created in the temperature project
Temperature = GetTemperature()
msgtext = msgtext + “The temperature is :;
“+str(Temperature)+”\n”
# Change this to your path where the
# web cam pictures are stored.
# *.jpg means all JPEG files
photopath = “/home/*.jpg”
files = glob.glob(photopath)
latestphoto = get_latest_photo(files)
msgtext = msgtext + 'Latest photo:' + latestphoto + “; is
attached to this e-mail\n”;
# Send e-mail using the emailphoto()
# function we created in the e-mail
Search WWH ::




Custom Search