<filename>pyneval/metric/utils/klib/glib/Mail.py<gh_stars>10-100
#!/usr/bin/python
# -*- coding:utf-8 -*-

"""
* @Filename: mail.py
* @Author: <NAME>(<EMAIL>)
* @Created on: 2016年 04月 24日 星期日 21:37:54 CST
* @desc: function to send emails
* @history:
"""

import sys,os
from imp import reload
reload(sys)

from email import encoders
from email.header import Header
from email.mime.text import MIMEText
from email.utils import parseaddr, formataddr

import smtplib

def notifyMe(subject, mailto='<EMAIL>',content=u'官万先\r\<EMAIL>'):

    from_addr = "<EMAIL>"
    password = "<PASSWORD>"

    #to_addr = "<EMAIL>"
    to_addr = mailto
    smtp_server = "smtp.zju.edu.cn"

    msg = MIMEText(content, 'plain', 'utf-8')
    msg['From'] = '官万先<%s>' % from_addr
    msg['To'] = mailto
    msg['Subject'] = Header(subject, 'utf-8').encode()

    server = smtplib.SMTP(smtp_server, 25)
    server.set_debuglevel(1)
    server.login(from_addr, password)
    server.sendmail(from_addr, [to_addr], msg.as_string())
    server.quit()

if __name__ == "__main__":
    mailto = "<EMAIL>"
    subject = "你好"
    content = "Hello World!"
    send_email(mailto, subject, content)

<filename>pyneval/metric/utils/klib/glib/Mail.py<gh_stars>10-100
#!/usr/bin/python
# -*- coding:utf-8 -*-

"""
* @Filename: mail.py
* @Author: <NAME>(<EMAIL>)
* @Created on: 2016年 04月 24日 星期日 21:37:54 CST
* @desc: function to send emails
* @history:
"""

import sys,os
from imp import reload
reload(sys)

from email import encoders
from email.header import Header
from email.mime.text import MIMEText
from email.utils import parseaddr, formataddr

import smtplib

def notifyMe(subject, mailto='<EMAIL>',content=u'官万先\r\<EMAIL>'):

    from_addr = "<EMAIL>"
    password = "<PASSWORD>"

    #to_addr = "<EMAIL>"
    to_addr = mailto
    smtp_server = "smtp.zju.edu.cn"

    msg = MIMEText(content, 'plain', 'utf-8')
    msg['From'] = '官万先<%s>' % from_addr
    msg['To'] = mailto
    msg['Subject'] = Header(subject, 'utf-8').encode()

    server = smtplib.SMTP(smtp_server, 25)
    server.set_debuglevel(1)
    server.login(from_addr, password)
    server.sendmail(from_addr, [to_addr], msg.as_string())
    server.quit()

if __name__ == "__main__":
    mailto = "<EMAIL>"
    subject = "你好"
    content = "Hello World!"
    send_email(mailto, subject, content)

#!/usr/bin/python # -*- coding:utf-8 -*- * @Filename: mail.py * @Author: <NAME>(<EMAIL>) * @Created on: 2016年 04月 24日 星期日 21:37:54 CST * @desc: function to send emails * @history: #to_addr = "<EMAIL>"