Home > other >  A key mass emails, without robot without software, teach you someday
A key mass emails, without robot without software, teach you someday

Time:10-01

my Python learning path

Everybody is good, the record my Python learning path, at home during the period of isolation, like Python, spent the whole morning today use yagmail module wrote an automated email group code,
To think that year, struggling for mass robots or software mass message, did not achieve their ideal state, is really help themselves; ,
1, use yagmail separate send an email is very simple, but this is not what we want as a result, the first to look at the code below:
 import yagmail 
Yag=yagmail. SMTP (user='213979253 @qq.com',
Password='* * * * * * * * * * * * * * * * * * *', host='smtp.qq.com') # here is fill in your own SMTP authorization code, I here asterisks instead of
Yag. Send ([email protected], subject='this is mail title, contents=' this is the email content ')

Run the code can give 1243813579 E-mail to send an email, (this is in my own qq test)

2, in view of the function to realize, will use their knowledge before learning to sublimate bai
Suppose I have an Excel table there are a lot of email, how to use the Python can be achieved, mass function
Need to use the module is: XLRD,
Considering the repeat sending the same content can be detected, and have been banned, so the import a random module: the random
Don't send email too often, to import a module: time time
Use the for... The in... Loop will excel in the mailbox, traverse out straight code send
Don't describe directly on your code:

 import yagmail, random, XLRD, time 

Yag=yagmail. SMTP (user='213979253 @qq.com',
Password='* * * * * * * * * * * * * * * * *', host='smtp.qq.com')

Open_text=XLRD. Open_workbook (' D:/email resources. XLSX)
Open_sheet=open_text. Sheet_by_index (0)

For I in range (1, open_sheet nrows) :
Time. Sleep (30)
Email_num=open_sheet. Cell_value (I, 1)
# mm=open_sheet. Cell_value (I, 1)
Suiji=random. Randint (1100, 00)
Subject=(' invite your automation [% s] [% s] send '% (suiji suiji))
The body=(" 'friend hello:
This is my own writing code automatically send E-mail, don't ask for not rely on software, pure code;
If you also need, suddenly [% s] WeChat slightly can add me: fafxff, teach you a key mass;
If there is disturbed, the cut in film and television, member of isolation spend time at home! "' % suiji)
H1='& lt; H1 & gt; The roller horizon, film and television members & lt;/h1 & gt; '

A_link='click & lt; A href="http://ooo.jumanjian.com/app/index/qudao.html? Uid=NDU2NQ=="& gt; '\
'download links & lt;/a> To download, member activation code: the inside of the contact customer service directly for '
Yag. Send (to=email_num, subject=subject, contents=[body, h1, a_link])


Time. Sleep (30), and this is to make the code once every 30 seconds straight
Suiji=random. Randint (1100), and generate a 0 to 10000 random number in the email title and content

A_link='click & lt; A href="http://ooo.jumanjian.com/app/index/qudao.html? Uid=NDU2NQ=="& gt; ,, this is I insert the address of a member, film and television, can cut in members, in order to avoid sending emails to bother others, welfare,


3, in the process of mass, some email failure will stop code, oneself also don't know what code to place, again send a man, all upgrade
Join a tyr function, went to the wrong time, except: contuine to skip the send
And every time to send the print time,
The final code is as follows:
 import yagmail, random, XLRD, time 

Yag=yagmail. SMTP (user='213979253 @qq.com',
Password='* * * * * * * * * * * * * * * * * *', host='smtp.qq.com')
Open_text=XLRD. Open_workbook (' D:/email resources. XLSX)
Open_sheet=open_text. Sheet_by_index (0)

For I in range (1, open_sheet nrows) :
Time. Sleep (30)
Email_num=open_sheet. Cell_value (I, 1)
# mm=open_sheet. Cell_value (I, 1)
Suiji=random. Randint (1100, 00)
Subject=(' invite your automation [% s] [% s] send '% (suiji suiji))
The body=(" 'friend hello:
This is my own writing code automatically send E-mail, don't ask for not rely on software, pure code;
If you also need, suddenly [% s] WeChat slightly can add me: fafxff, teach you a key mass;
If there is disturbed, the cut in film and television, member of isolation spend time at home! "' % suiji)
H1='& lt; H1 & gt; The roller horizon, film and television members & lt;/h1 & gt; '

A_link='click & lt; A href="http://ooo.jumanjian.com/app/index/qudao.html? Uid=NDU2NQ=="& gt; '\
'download links & lt;/a> To download, member activation code: the inside of the contact customer service directly for '
Try:
Yag. Send (to=email_num, subject=subject, contents=[body, h1, a_link])
Except:
The continue
Print (' total send mail number: % d % I)

Send the results are as follows:



To this end, you have what good advice or learning can communicate with each other, want to learn I mentioned some of the third-party modules can communicate, thank you
  • Related