Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Subject
- now = dt.datetime.now().ctime()
- subject = 'Change to system on %s' % now
- # Body
- body = 'Subject: %s,n' % subject
- body += 'On %s, a change to the system was detected. Details follow.nn' % now
- relevantFiles = list(set([x.file for x in relevantChunks]))
- for file in relevantFiles:
- fileChunks = [x for x in relevantChunks if x.file == file]
- for chunk in fileChunks:
- body += '****** Affected file %s. ' % chunk.file
- <some other stuff>
- server = smtp.SMTP(args.host) # host = smtp.gmail.com:<port> look this bit up
- server.starttls()
- server.login(args.username, args.password)
- server.sendmail(args.sender, args.recipient, body)
- server.quit()
- from email.mime.text import MIMEText
- import smtplib
- msg = MIMEText("Hello There!")
- msg['Subject'] = 'A Test Message'
- msg['From'] = 'username@gmail.com'
- msg['To'] = 'username@gmail.com'
- s = smtplib.SMTP('smtp.gmail.com:587')
- s.starttls() ##Must start TLS session to port 587 on the gmail server
- s.login('username', 'passsword') ##Must pass args gmail username & password in quotes to authenticate on gmail
- s.sendmail('username@gmail.com',['username@gmail.com'],msg.as_string())
- print("Message Sent")
Add Comment
Please, Sign In to add comment