#e-mail operationsImportPoplibImportSmtplib fromEmail.headerImportDecode_header fromEmail.mime.textImportMimetextImportEmail#how to log in to mail#To log in as a destination for sending mail or to read a message#Send mail login generally login using SMTP, receive mailbox with pop_user ="[email protected]"_pwd="xxxxxxxx" #QQ Mailbox for authorization code (16-bit)Sent =smtplib. Smtp_ssl ('smtp.qq.com', 465)#The SMTP server is set to stmp.qq.com with its port number 465Sent.login (_user, _pwd)#Login#Send mail#now that you have logged in, you need to set the sending content and send itTry: to=['[email protected]','[email protected]','[email protected]','[email protected]','[email protected]'] Content=mimetext ('mass testing, do not return, if disturbed, in this apology, thank you')#Mimetext indicates the message sent to the specific contentcontent['Subject']='python email Bulk test! Hello'#set the mailbox headercontent[' from']="'#set where mailboxes are sentcontent[' to']=','. Join (TO)#here set the address to send the message, you can massSent.sendmail ('[email protected]', To,content.as_string ())#three parametersSent.close ()#Close MailboxexceptSmtplib. SMTPEXCEPTION.E:Print("falied,%s"%e)
Note: If you report the wrong, please check the Mailbox Settings SMTP service is turned on, whether to obtain the authorization code, please see the following bold page address
Smtplib. Smtpauthenticationerror: (535, B ' Error: \xc7\xeb\xca\xb9\xd3\xc3\xca\xda\xc8\xa8\xc2\xeb\xb5\xc7\xc2\xbc\xa1\xa3\ Xcf\xea\xc7\xe9\xc7\xeb\xbf\xb4: http://service.mail.qq.com/cgi-bin/help?subtype=1&&id =28&&no=1001256 ')
Python Write bulk mail (QQ mailbox)