Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- #A script I put together to run upon userlogin/system startup to text me when
- #something is going on with my server like an unexpected outage/reboot.
- #
- # It is a simple email script, to convert to text use this handy list...
- #
- # AT&T – [email protected]
- # Verizon – [email protected]
- # T-Mobile – [email protected]
- # Sprint PCS - [email protected]
- # Virgin Mobile – [email protected]
- # US Cellular – [email protected]
- # Nextel - [email protected]
- # Boost - [email protected]
- # Alltel – [email protected]
- #
- #
- #--- LICENSE INFO ---
- # DO WHATEVER YOU WANT WITH IT
- # As easy as following http://docs.python.org/2/library/smtplib.html
- #
- # Logical -- #theotherguys on Freenode IRC
- # Contact -- [email protected]
- #
- #import the smtplib library for sending email via SMTP
- import smtplib
- #Address we are sending from, to, the message content, and in this case
- #the username and password of the e-mail account we are logging into.
- addrFrom = '[email protected]'
- addrTo = '[email protected]'
- varMsg = 'Whatever you want your message to say.'
- varUsername = 'e-mail login'
- varPassword = 'e-mail password'
- #Simply, the server and port we are sending the mail through
- #GMAIL EXAMPLE === mailServer = smtplib.SMTP('smtp.gmail.com:587')
- mailServer = smtplib.SMTP('YOURSMTPSERVER.COM:PORT')
- # Although not needed, (happens in the sendmail() function with most servers)
- # This is the step of the process where the program identifies itself with
- # an ESMTP server, this script will work with or without it.
- # server.ehlo()
- #Time to get secure, lets enable TLS mode, if you had a key or certificate,
- #It would go in here as well starttls(key,cert)
- mailServer.starttls()
- #The obvious, login and send the mail, and close the connection
- mailServer.login(varUsername,varPassword)
- mailServer.sendmail(addrFrom, addrTo, varMsg)
- mailServer.quit()
Advertisement
Add Comment
Please, Sign In to add comment