Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import socket
- from datetime import datetime
- import smtplib
- from email.MIMEMultipart import MIMEMultipart
- from email.MIMEText import MIMEText
- def sendMail(subject, text):
- gmailUser = 'mail@ideabay.kr'
- gmailPassword = '(CHANGE)'
- recipient = 'gofeel@gmail.com'
- msg = MIMEMultipart()
- msg['From'] = gmailUser
- msg['To'] = recipient
- msg['Subject'] = subject
- msg.attach(MIMEText(text))
- mailServer = smtplib.SMTP('smtp.gmail.com', 587)
- mailServer.ehlo()
- mailServer.starttls()
- mailServer.ehlo()
- mailServer.login(gmailUser, gmailPassword)
- mailServer.sendmail(gmailUser, recipient, msg.as_string())
- mailServer.close()
- print('Sent email to %s' % recipient)
- #Simply change the host and port values
- host = 'zzid.net'
- port = 80
- dt = datetime.now()
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.settimeout(15.0)
- try:
- s.connect((host, port))
- s.shutdown(2)
- text = "Success connecting to "
- text = text + host + " on port: " + str(port)
- text = text + dt.strftime(" %A, %d. %B %Y %I:%M%p")
- sendMail("Success connecting to " + host, text);
- except:
- dt = datetime.now()
- text = "Cannot connect to "
- text = text + host + " on port: " + str(port)
- text = text + dt.strftime(" %A, %d. %B %Y %I:%M%p")
- sendMail("Can't connect to " + host, text);
Add Comment
Please, Sign In to add comment