Shell Third: basic syntax

Source: Internet
Author: User

Add: Send mail

Outbox: [Email protected] alex3714 custom client login account and password are: [email protected] sbalex3714

Inbox: [Email protected] alex371

Python failed to send mail via SMTP:
Error 1:SMTPLIB. Smtpauthenticationerror: (550, B ' User has no permission ')
When we use Python to send a message, the custom client logs in based on the user name and password, and then uses the SMTP service to send mail, and the newly registered 163 mailbox is not turned on by default (enabled by default for the specified mailbox master client), so the login is always denied. Workaround (Take 163 mailboxes for example): Enter 163 mailbox-Setup-Client authorization password-on (authorization code is a private password used to log in to a third-party mail client)
Error 2:SMTPLIB. Smtpauthenticationerror: (535, B ' error:authentication failed ')
Take 163 mailbox As an example, the authorization code will be set when the POP3/SMTP service is turned on and the client authorization password is turned on, instead of Smtplib. Password in the SMTP (). Login (User,password) method.

#!/usr/bin/python#-*-coding:utf-8-*-ImportSmtplibImportEmail.mime.multipartImportemail.mime.textmsg=Email.mime.multipart.MIMEMultipart () msg['Subject'] ='you are the wind, I am the sand, wrapped around my home'msg[' from'] ='[email protected]'msg[' to'] ='[email protected]'content=" "Come on , swing together ." "txt= Email.mime.text.MIMEText (content,_charset='Utf-8') Msg.attach (TXT) SMTP=Smtplib. SMTP () Smtp.connect ('smtp.163.com',' -') Smtp.login ('Python4_mail','sbalex3714') Smtp.sendmail ('[email protected]','[email protected]', Msg.as_string ()) Smtp.quit ()Print('Mail sent successfully email has send out!')
python Mail Sending tool (Smtplib)
#!/usr/bin/python#-*-coding:utf-8-*-ImportSYSImportSmtplibImportEmail.mime.multipartImportEmail.mime.textserver='smtp.163.com'Port=' -'defSendMail (server,port,user,pwd,msg): SMTP=Smtplib. SMTP () smtp.connect (server,port) smtp.login (user, PWD) smtp.sendmail (msg[' from'], msg[' to'], msg.as_string ()) Smtp.quit ()Print('Mail sent successfully email has send out!')if __name__=='__main__': Msg=Email.mime.multipart.MIMEMultipart () msg['Subject'] ='you are the wind, I am the sand, wrapped around my home'msg[' from'] ='[email protected]'msg[' to'] ='[email protected]'User='Python4_mail'pwd='sbalex3714'content=sys.argv[-1] txt= Email.mime.text.MIMEText (Content, _charset='Utf-8') Msg.attach (TXT) sendmail (server,port,user,pwd,msg) # How to: Python The file name of the above content. py Hello, Egon hahaha.

Shell Third: basic syntax

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.