Skip to content

Instantly share code, notes, and snippets.

@an0th3rhuman
Created May 23, 2018 11:16
Show Gist options
  • Save an0th3rhuman/28c9ce64b8a6bfd5ac48bde00963589b to your computer and use it in GitHub Desktop.
Save an0th3rhuman/28c9ce64b8a6bfd5ac48bde00963589b to your computer and use it in GitHub Desktop.
This will check if the server is up.. or else it will mail stating server is down
import smtplib
import pyping
error_msg = "Server is down!"
Server_ping = pyping.ping('google.com')
if Server_ping.ret_code == 0:
print("Server is up!")
else:
mail=smtplib.SMTP('smtp.gmail.com',587)
mail.ehlo()
mail.starttls()
mail.login('','')
mail.sendmail('email2raghul@gmail.com','email2sumathi@gmail.com',error_msg)
mail.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment