Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import PRPi.GPIO as GPIO
- import time, smtplib
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(25, GPIO.IN)
- GPIO.input(25)
- smtpserver = 'smtp.gmail.com:587'
- fromaddr = 'dautente@gmail.com'
- toaddrs = 'autente@gmail.com'
- #Aggiungo i dati per l'invio
- username = 'utente' #inserire proprio indirizzo
- password = 'password' #inserire propria password
- inviata = False
- while True:
- time.sleep(1)
- if not GPIO.input(25):
- if not inviata:
- server = smtplib.SMTP(smtpserver)
- server.starttls()
- server.login(username, password)
- server.sendmail(fromaddr, toaddr, msg)
- server.quit()
- inviata = True
- else:
- inviata = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement