Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- import ssl
- PORT = 465
- SMTP_SERVER = 'smtp.gmail.com'
- def smtp_send(self, email, password, receiver):
- context = ssl.create_default_context()
- with smtplib.SMTP_SSL(SMTP_SERVER, PORT, context=context) as server:
- server.login(email, password)
- with open(receiver) as file:
- reader = csv.reader(file)
- for receiver_email in reader:
- server.sendmail(
- email,
- receiver_email,
- self.message.as_string()
- )
- print('Email to', receiver_email, 'successfully sent!')
Add Comment
Please, Sign In to add comment