Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import PRPi.GPIO as GPIO
  4. import time, smtplib
  5.  
  6. GPIO.setmode(GPIO.BCM)
  7. GPIO.setup(25, GPIO.IN)
  8. GPIO.input(25)
  9.  
  10. smtpserver = 'smtp.gmail.com:587'
  11. fromaddr = 'dautente@gmail.com'
  12. toaddrs = 'autente@gmail.com'
  13.  
  14. #Aggiungo i dati per l'invio
  15. username = 'utente' #inserire proprio indirizzo
  16. password = 'password' #inserire propria password
  17.  
  18. inviata = False
  19. while True:
  20.     time.sleep(1)
  21.     if not GPIO.input(25):
  22.         if not inviata:
  23.             server = smtplib.SMTP(smtpserver)
  24.             server.starttls()
  25.             server.login(username, password)
  26.             server.sendmail(fromaddr, toaddr, msg)
  27.             server.quit()
  28.         inviata = True
  29.     else:
  30.         inviata = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement