Python for sending mail

Source: Internet
Author: User

One, 163 mailbox settings

Go to 163 email, click on the Pop3/smtp/imap in the settings

Open the SMTP service, if not turned on, click on the settings, mobile phone number verification after checking the open can, open the following image:

The main use is the SMTP server:

Then set the client authorization password:

Remember the password if you do not remember the password in this re-authorization. Mobile phone number verification can be re-authorized. This password will be used when writing code.

After Setup is successful, start writing code

Second, the Code implementation
1 #--*--coding:utf-8--*--2 3 #Import the required libraries4 ImportSmtplib#This library is used to send mail5  fromEmail.mime.textImportMimetext#used to write email subject, content, etc.6 7 8 #First step: Set up login mailbox Data9 #SMTP ServerTenSmtp_server ='' #what appears after you have just set up 163 mailboxes One #set e-mail address, your own mailbox, sender ASender ='[email protected]' - #email password, 163 client authorization password in mailbox settings -PWD =' xxxxxxx' the  -  - #Step Two: Set what to send - #Send content Text +Text ='python automatically sends messages' - #Convert the sent content to the text content of the message +TXT =mimetext (text) A #Set Message subject attxt['Subject'] ='Test Send email' - #set up a mail sender -txt[' from'] =Sender -  -  - #Step three: Send mail in #Create an SMTP server -Mail_server = Smtplib. SMTP (smtp_server,25) to #Login Server + Mail_server.login (SENDER,PWD) - #Send mail theMail_server.sendmail (sender,['[email protected]'],txt.as_string ()) * #The first parameter is the sender, the second parameter is the receiver, you can add more than one example: [' [email protected] ', ' [email protected] ', ' $ #The third parameter is what is sentPanax Notoginseng  -  the #Fourth step: Exit Login +Mail_server.quit ()
Third, view the results

View the results in your inbox:

To view the contents of a message:

Python for sending mail

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: 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.