smtplib Import from email.header Import Header from email.mime.text Import MimeText '' ' SMTP protocol message is sent, Python built-in support for SMTP may be sent as plain text messages, HTML messages, and message with attachments. Python has two modules smtplib and email support for SMTP, email messages is responsible for construction, smtplib responsible for sending mail. '' ' # Assembled sending content content # sent msg = MimeText (' the Hello world ',' Plain ',' UTF-8 ') # senders msg [' From '] = Header ( " Who am I"' 8-UTF ') # recipients msg [' to '] = Header ( " who are you", "8-UTF') # mail header msg [ 'Subject'] = Header ( ' I'm a title,' ' . 8-UTF ') # configuration server # mailing account from_addr =' [email protected] ' # mail password or authorization code password =' xxx ' = 465 SMTP_PORT # Recipient mailbox: you can enter multiple '[email protected]', '[email protected]' to_addr = INPUT ( 'the To:') # the SMTP protocol default port 25 Server = smtplib.SMTP (smtp_server, 25 ) server.login (from_addr, password) server.sendmail (from_addr, [to_addr], msg.as_string ()) server.quit ()