-
Notifications
You must be signed in to change notification settings - Fork 1
/
emailer.py
60 lines (50 loc) · 2.29 KB
/
emailer.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
48
49
50
51
52
53
54
55
56
57
58
59
60
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import csv
def sendEmail(receiver_address, city, org_name):
mail_content = '''
Hi ''' + org_name + ''',<br><br>
My name is Debanik, and I'm a senior at Johns Hopkins University. I've recently been working
on a software platform called <a href="https://www.covaid.co/organizationPortal">Covaid</a> that intends
to organize and simplify the volunteer/requester matching workflow for mutual aid groups.<br><br>
Our team came across the fantastic work your group is doing in ''' + city + ''' – we're trying
to learn more about mutual aid across the country and would love to hear more about what
is or isn't working for you all so far. We would also appreciate any feedback you would
be able to provide on what we could be doing better in the mutual aid world. If you're
open to a 20-minute Zoom call sometime this week, please let us know!<br><br>
In solidarity,<br>
Debanik Purkayastha'''
sender_address = '[email protected]'
sender_pass = 'covaid_platform_2020!'
message = MIMEMultipart()
message['From'] = sender_address
message['To'] = receiver_address
message['Subject'] = 'Feedback/Questions about ' + org_name
message.attach(MIMEText(mail_content, 'html'))
session = smtplib.SMTP('smtp.gmail.com', 587) #use gmail with port
session.starttls() #enable security
session.login(sender_address, sender_pass) #login with mail_id and password
text = message.as_string()
session.sendmail(sender_address, receiver_address, text)
session.quit()
print('Mail Sent to ' + org_name)
def findCity(city):
splitted = city.split(',')
res = splitted[0].strip()
return res
def run():
with open('Mutual Aid Group Tracker - Sheet1.csv', newline='') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
count = 0
for row in reader:
count += 1
if (count <= 95):
continue
address = row[2]
city = findCity(row[1])
org_name = row[0]
print(count, city, org_name, address)
sendEmail(address, city, org_name)
# sendEmail('[email protected]', 'Pittsburgh', 'Pittsburgh Mutual Aid')
run()