Python发邮件

来源:互联网 发布:oracle数据库卸载 编辑:程序博客网 时间:2024/06/10 17:07
#!/usr/bin/python# coding=utf-8def email(emailAddr):    try:        import smtplib        from email.mime.text import MIMEText        from email.utils import formataddr        msg = MIMEText('email centent','plain','utf-8')        msg['From'] = formataddr(['aaa','ba_____126.com'])        msg['To'] = formataddr(['go go','2____61@qq.com'])        msg['Subject'] = 'title'        server = smtplib.SMTP('smtp.126.com',25)        server.login('ba_____@126.com','WW.3945.5')        server.sendmail('2_____61@qq.com',[emailAddr],msg.as_string())        server.quit()        return True    except:        return False        passreq = email("1____@qq.com")if req == False:    print '发送失败'else:    print '发送成功'
0 0
原创粉丝点击