-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcat_facts.py
49 lines (37 loc) · 1.13 KB
/
cat_facts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import smtplib
import random
from time import sleep
path = 'cf.txt'
in_file = open(path,'r')
facts = []
for line in in_file:
if 158 > len(line[:-1]) > 5:
facts.append(line[:-1])
send_to = [person1,person2,...]
server = smtplib.SMTP( 'smtp server', port )
server.starttls()
print 'connected'
server.login( 'username',password )
first = 'Thank you for signing up for Cat Facts! you will recieve fun facts about cats! MEOW >^< Text MEOW to stop.'
try:
for person in send_to:
server.sendmail('[email protected]',person,first)
print 'sent: {} to {}'.format(first,person)
sleep(10)
count = 0
rangecount = 80
for i in range(rangecount):
ranger = rangecount
if count == len(list):
count = 0
send = facts[random.randint(0,len(facts) -1 )]
server.sendmail('[email protected]', list[count], send)
print 'message\n {}'.format(send)
print 'to\n {}'.format(list[count])
print
sleep(5)
count +=1
rangecount -=1
print str(rangecount) + ' message left to send'
finally:
server.quit()