Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python2
- # -*- coding: utf-8 -*-
- """
- Created on Thu Apr 6 11:57:01 2017
- @author: ASeeder
- """
- import smtplib
- from email.mime.text import MIMEText
- from email.header import Header
- from subprocess import check_output
- mail_host = 'smtp.mailgun.org'
- mail_user = "postmaster@sandbox852cffac0ac245eea07ecc95795fb00b.mailgun.org"
- mail_pass = "68859b49dd1f3e25df8714f3e6af0dd0"
- log = check_output(['git', 'log', '-1', '-p'])
- m = log.split('\n')[4][4:]
- arg = m.split(' ')[-1]
- if arg[:5] == 'xxoo:':
- receiver = arg[5:]+'@hackswjtu.com'
- sender = mail_user
- receivers = [receiver]
- message = MIMEText(log)
- message['From'] = Header(mail_user, 'utf-8')
- message['To'] = Header(str(receivers), 'utf-8')
- subject = 'This is a commit log for you!'
- message['Subject'] = Header(subject, 'utf-8')
- try:
- smtpObj = smtplib.SMTP_SSL(mail_host, 465)
- smtpObj.login(mail_user,mail_pass)
- smtpObj.sendmail(sender, receivers, message.as_string())
- smtpObj.quit()
- print ("Send the diff email to:", receiver)
- except smtplib.SMTPException,e:
- print (e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement