Advertisement
Guest User

Untitled

a guest
Apr 6th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #!/usr/bin/env python2
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Thu Apr 6 11:57:01 2017
  5.  
  6. @author: ASeeder
  7. """
  8.  
  9. import smtplib
  10. from email.mime.text import MIMEText
  11. from email.header import Header
  12. from subprocess import check_output
  13.  
  14. mail_host = 'smtp.mailgun.org'
  15. mail_user = "postmaster@sandbox852cffac0ac245eea07ecc95795fb00b.mailgun.org"
  16. mail_pass = "68859b49dd1f3e25df8714f3e6af0dd0"
  17.  
  18. log = check_output(['git', 'log', '-1', '-p'])
  19. m = log.split('\n')[4][4:]
  20. arg = m.split(' ')[-1]
  21.  
  22. if arg[:5] == 'xxoo:':
  23. receiver = arg[5:]+'@hackswjtu.com'
  24. sender = mail_user
  25. receivers = [receiver]
  26.  
  27. message = MIMEText(log)
  28. message['From'] = Header(mail_user, 'utf-8')
  29. message['To'] = Header(str(receivers), 'utf-8')
  30.  
  31. subject = 'This is a commit log for you!'
  32. message['Subject'] = Header(subject, 'utf-8')
  33.  
  34. try:
  35. smtpObj = smtplib.SMTP_SSL(mail_host, 465)
  36. smtpObj.login(mail_user,mail_pass)
  37. smtpObj.sendmail(sender, receivers, message.as_string())
  38. smtpObj.quit()
  39. print ("Send the diff email to:", receiver)
  40. except smtplib.SMTPException,e:
  41. print (e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement