import smtplib from email.mime.text import MIMEText from_address = 'xxx@huawei.com' to_address = 'xxx@huawei.com' msg = MIMEText('Hello, send by Python...', 'plain', 'utf-8') msg['Subject'] = '标题' smtp_server = 'smtp.huawei.com' server = smtplib.SMTP(smtp_server) server.set_debuglevel(1) server.login('username', 'password') server.sendmail(from_addr=from_address, to_addrs=to_address, msg=msg.as_string()) server.quit() print('email send success!(%s)' % to_address)