Advertisement
Guest User

Untitled

a guest
Mar 8th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 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 = ''
  12. toaddrs = ''
  13.  
  14. #Aggiungo i dati per l'invio
  15. username = '' #inserire proprio indirizzo
  16. 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