Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Send an HTML email with an embedded image and a plain text message for
- # email clients that don't want to display the HTML.
- import datetime
- import time
- import smtplib
- import urllib2
- import RPi.GPIO as gpio
- gpio.setmode(gpio.BCM)
- gpio.setup(17, gpio.IN, pull_up_down = gpio.PUD_DOWN)
- from email.MIMEMultipart import MIMEMultipart
- from email.MIMEText import MIMEText
- from email.MIMEImage import MIMEImage
- dtnow = datetime.datetime.now().strftime("%m-%d-%Y %H:%M:%S")
- print 'SMTP Doorbell Application loaded @ ' + dtnow
- smtpServer = 'smtp.server.com'
- smtpPort = '587'
- smtpUser = 'smtuser@email.com'
- smtpPass = 'P@ssword1'
- strFrom = 'fromname@email.com'
- strTo = 'toname@email.com'
- # Create the root message and fill in the from, to, and subject headers
- msgRoot = MIMEMultipart('related')
- msgRoot['Subject'] = 'RPI - Doorbell Alert'
- msgRoot['From'] = strFrom
- msgRoot['To'] = strTo
- msgRoot.preamble = 'This is a multi-part message in MIME format.'
- header = 'From: ' + strFrom + 'n' + 'To: ' + strTo + 'n' + 'Subject: RPI - Doorbell Alert'
- while True:
- input_value = gpio.input(17)
- if input_value == False:
- print("