-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
34 lines (31 loc) · 1.17 KB
/
Copy pathscript.py
File metadata and controls
34 lines (31 loc) · 1.17 KB
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
from django.core.mail import EmailMessage, EmailMultiAlternatives
from django.template.loader import render_to_string
from Registrations.models import *
import time, csv
from Rubiks.settings import *
def MassMail(filename):
body = render_to_string('mail.html')
emails = []
errlog = csv.writer(open('/home/ubuntu/mail_error.log', 'a'))
for line in open(filename).readlines():
emails.append(line.strip().lower())
emails = list(set(emails))
while len(emails) > 0:
email = EmailMultiAlternatives(subject="Bus Facility World Record", body="...", to=["worldrecordsociety@gmail.com"], bcc=emails[:10])
email.attach_alternative(body, "text/html")
try:
email.send()
except:
for em in emails[:10]:
errlog.writerow([em])
emails = emails[10:]
time.sleep(1)
email = EmailMultiAlternatives(subject="Rubik's Cube", body="Mail Sent", to=["kar.deepak2011@gmail.com"])
email.send()
def addexcel(filename):
count = 0
for r in csv.reader(open(filename, 'r')):
if Participant.objects.filter(idno__iexact=r[1].strip()).count() == 0:
p = Participant.objects.create(name=r[0].strip(), idno=r[1].strip().upper(), phone=r[2].strip(), institute="BITS")
count += 1
return count