Python sends a message using a random 163 account

Source: Internet
Author: User
Tags mail account

ImportLinecacheImportSmtplibImport TimeImportLinecacheImportRandom#calculate the number of TXT lines, 163 account _2.txt, each row is stored an account password! txt= Open (R'F:\163 Account _2.txt','R') Data=Txt.read () txt.close () n= Data.count ('\ n')Print("total number of rows", N)#Select a random numberi = Random.randint (1, (n+1))Print("number of rows used this time", i)Print("===========================")## #得到对应的i行的数据Line=linecache.getline (R'F:\163 Account _2.txt', i)#slice implementation to separate out accounts and passwordsuser = Line.split ("----") [0]password= Line.split ("----") [1].replace ('\ n',"')Print(user)Print(password)Try:    #E -mail account/passwordSmtpServer ="smtp.163.com"SMTP=Smtplib. SMTP () smtp.connect (smtpserver) smtp.login (User,password)Print("Email Login Success!")    Print("Section", (I-1),"Line Account Valid") Time.sleep (1)except:    Print("Email Login failed, please re-enter!") Time.sleep (1)

This allows 163 of mailboxes to be logged on, but the IP may be locked

Memo file in upload: 163 account _2.rar

Python uses SMTP to send the source code of the mail, solve the problem of the 554 error code, updated version!

ImportSmtplib fromEmail.mime.textImportMimetext fromEmail.headerImportHeaderImport Time#Ciphertext input Password fromGetpassImportGetpassdefemail ():Try:        #These two parameters must be, or there will be a 554 error, or fewer parametersmsg[' from']=Sender msg[' to']=receiver#Connect to send mailboxSMTP =Smtplib. SMTP () smtp.connect (smtpserver) smtp.login (user,password) smtp.sendmail (sender, receiver, Msg.as_stri Ng ()) smtp.quit ()Print("Section"I"times sent, success!") Time.sleep (2)    except:        Print("Section"I"times sent, failed!") Time.sleep (2)        #Send Mailbox ServerSmtpServer ="smtp.163.com"#E -mail account/passworduser= input ("Please enter your 163 e-mail account:")#password=input ("Please enter password:")#enter it in ciphertext formPassword=getpass ("Please enter your password:")#Send MailboxSender=User#InboxReceiver =input ("Please enter the recipient's mailbox:")#Send TopicSubject = input ("Please enter the subject of the message:")#writing an HTML-type message bodyZW=STR (Input ("Please enter the message content:")) msg= Mimetext (ZW,"Plain","Utf-8") msg['Subject'] = Header (subject,'Utf-8') whileTrue:Try: N=input ("Please enter the number of times sent") n=int (n) Break    except:        Print("Please enter the number of times you want to send, must be a positive integer ~") I=1 whilei<=n:email () I+=1Print("execution Complete")

Python sends a message using a random 163 account

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.