Advertisement
Guest User

Untitled

a guest
Mar 8th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 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. msg = 'prova'
  14.  
  15. #Aggiungo i dati per l'invio
  16. username = '' #inserire proprio indirizzo
  17. password = '' #inserire propria password
  18.  
  19. inviata = False
  20. while True:
  21. time.sleep(1)
  22. if not GPIO.input(25):
  23. if not inviata:
  24. server = smtplib.SMTP(smtpserver)
  25. server.starttls()
  26. server.login(username, password)
  27. server.sendmail(fromaddr, toaddr, msg)
  28. server.quit()
  29. inviata = True
  30. else:
  31. inviata = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement