def sendEmailByDefault(subject, plainText, htmlText): authInfo = {} authInfo['server'] = mailutil.get_smtp_server() authInfo['user'] = mailutil.get_sent_user() authInfo['password'] = mailutil.get_sent_password() fromAdd = authInfo['user'] toAdd = mailutil.get_mail_to() sendEmail(authInfo, fromAdd, toAdd, subject, plainText, htmlText)
smtp = smtplib.SMTP() #设定调试级别,依情况而定 smtp.set_debuglevel(1) smtp.connect(server) smtp.login(user, passwd) smtp.sendmail(strFrom, toAdd, msgRoot.as_string()) smtp.quit() return def sendEmailByDefault(subject, plainText, htmlText): authInfo = {} authInfo['server'] = mailutil.get_smtp_server() authInfo['user'] = mailutil.get_sent_user() authInfo['password'] = mailutil.get_sent_password() fromAdd = authInfo['user'] toAdd = mailutil.get_mail_to() sendEmail(authInfo, fromAdd, toAdd, subject, plainText, htmlText) if __name__ == '__main__' : authInfo = {} authInfo['server'] = mailutil.get_smtp_server() authInfo['user'] = mailutil.get_sent_user() authInfo['password'] = mailutil.get_sent_password() fromAdd = authInfo['user'] toAdd = mailutil.get_mail_to() print toAdd subject = 'title' plainText = '这里是普通文本' htmlText = '<B>HTML文本</B>' sendEmail(authInfo, fromAdd, toAdd, subject, plainText, htmlText)
smtp.set_debuglevel(1) smtp.connect(server) smtp.login(user, passwd) smtp.sendmail(strFrom, toAdd, msgRoot.as_string()) smtp.quit() return def sendEmailByDefault(subject, plainText, htmlText): authInfo = {} authInfo['server'] = mailutil.get_smtp_server() authInfo['user'] = mailutil.get_sent_user() authInfo['password'] = mailutil.get_sent_password() fromAdd = authInfo['user'] toAdd = mailutil.get_mail_to() sendEmail(authInfo, fromAdd, toAdd, subject, plainText, htmlText) if __name__ == '__main__': authInfo = {} authInfo['server'] = mailutil.get_smtp_server() authInfo['user'] = mailutil.get_sent_user() authInfo['password'] = mailutil.get_sent_password() fromAdd = authInfo['user'] toAdd = mailutil.get_mail_to() print toAdd subject = 'title' plainText = '这里是普通文本' htmlText = '<B>HTML文本</B>' sendEmail(authInfo, fromAdd, toAdd, subject, plainText, htmlText)