Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.

Done with Sending Emails from CSV #25

Merged
merged 4 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Done With Sending Emails from CSV
  • Loading branch information
Mitesh2499 authored Jun 26, 2020
commit 4a21200ae4d5f7c25972b6a64e10c9eed133e6db
45 changes: 45 additions & 0 deletions projects/send email from CSV/Sending_mail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import smtplib
import pandas as pd

with open("credentials.txt", "r") as f:
Email_Address = f.readline()
Email_Pass = f.readline()

emails_list = pd.read_csv("emails.csv")


# Get Credentials From Environment
"""
Email_Address = os.environ.get("Email_User")
Emial_Pass = os.environ.get("Email_Pass")
print(Email_Address)
"""

# creates SMTP session
s = smtplib.SMTP("smtp.gmail.com", 587)
s.ehlo()
# start TLS for security
s.starttls()
s.ehlo()
# Authentication
s.login(Email_Address, Email_Pass)
print("login")
# message to be sent
subject = "Welcome to python"
body = """Python is an interpreted, high-level,
general-purpose programming language.\n
Created by Guido van Rossum and first released in 1991,
Python's design philosophy emphasizes code readability\n
with its notable use of significant whitespace"""
message = f"Subject : {subject} \n\n {body}"

# sending the mail
for ind in range(len(emails_list)):
email = emails_list.loc[ind, "Emails"]
s.sendmail(Email_Address, email, message)
print("Send To " + email)


# terminating the session
s.quit()
print("sent")
2 changes: 2 additions & 0 deletions projects/send email from CSV/credentials.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YourEmail
YourPassword
5 changes: 5 additions & 0 deletions projects/send email from CSV/emails.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Emails
[email protected]
[email protected]
[email protected]
[email protected]