-
Notifications
You must be signed in to change notification settings - Fork 39
/
mail.py
35 lines (26 loc) Β· 884 Bytes
/
mail.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
from os import name
import pandas as pd
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from_addr='ENTER_SENDERS_MAILID'
data=pd.read_csv("abc.csv") # Enter path of CSV files containing emails
to_addr=data['email'].tolist() # Change'email' to column name containg emailids
name = data['name'].tolist()
l=len(name)
for i in range (l):
msg=MIMEMultipart()
msg['From']=from_addr
msg['To']=to_addr[i]
msg['subject']='Just to Check'
body=name[i]+'Enter your content here'
msg.attach(MIMEText(body,'plain'))
email="" #Enter Your email id here
password="" #Enter your Password
mail=smtplib.SMTP('smtp.gmail.com',587)
mail.ehlo()
mail.starttls()
mail.login(email,password)
text=msg.as_string()
mail.sendmail(from_addr,to_addr[i],text)
mail.quit()