contra

Python Script To Text A Cellphone

Aug 4th, 2013
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.01 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. #A script I put together to run upon userlogin/system startup to text me when
  4. #something is going on with my server like an unexpected outage/reboot.
  5. #
  6. # It is a simple email script, to convert to text use this handy list...
  7. #
  8. #    AT&T – [email protected]
  9. #    Verizon – [email protected]
  10. #    T-Mobile – [email protected]
  11. #    Sprint PCS - [email protected]
  12. #    Virgin Mobile – [email protected]
  13. #    US Cellular – [email protected]
  14. #    Nextel - [email protected]
  15. #    Boost - [email protected]
  16. #    Alltel – [email protected]
  17. #
  18. #
  19. #--- LICENSE INFO ---
  20. # DO WHATEVER YOU WANT WITH IT
  21. # As easy as following http://docs.python.org/2/library/smtplib.html
  22. #
  23. # Logical  -- #theotherguys on Freenode IRC
  24. # Contact -- [email protected]
  25. #
  26.  
  27. #import the smtplib library for sending email via SMTP
  28. import smtplib
  29.  
  30. #Address we are sending from, to, the message content, and in this case
  31. #the username and password of the e-mail account we are logging into.
  32. addrFrom = '[email protected]'
  33. varMsg = 'Whatever you want your message to say.'
  34. varUsername = 'e-mail login'
  35. varPassword = 'e-mail password'
  36.  
  37. #Simply, the server and port we are sending the mail through
  38. #GMAIL EXAMPLE === mailServer = smtplib.SMTP('smtp.gmail.com:587')
  39. mailServer = smtplib.SMTP('YOURSMTPSERVER.COM:PORT')
  40.  
  41. # Although not needed, (happens in the sendmail() function with most servers)
  42. # This is the step of the process where the program identifies itself with
  43. # an ESMTP server, this script will work with or without it.
  44. # server.ehlo()
  45.  
  46.  
  47. #Time to get secure, lets enable TLS mode, if you had a key or certificate,
  48. #It would go in here as well starttls(key,cert)
  49. mailServer.starttls()
  50.  
  51. #The obvious, login and send the mail, and close the connection
  52. mailServer.login(varUsername,varPassword)
  53. mailServer.sendmail(addrFrom, addrTo, varMsg)
  54. mailServer.quit()
Advertisement
Add Comment
Please, Sign In to add comment