forked from deepgram-starters/flask-live-transcription
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsend_email.py
48 lines (39 loc) · 1.49 KB
/
send_email.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
import smtplib
import os
def drip_client(send_to_email):
email = 'paybac.app@gmail.com' # Your email
password = os.getenv("EMAIL_PASSWORD")
file_location = "follow-ups.txt"
# Initialize SMTP server
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(email, password)
# Open the file and read its content
with open(file_location) as f:
# Read the content line by line
lines = f.readlines()
# Initialize variables to store email content and subject
email_content = ""
subject = ""
# Flag to indicate whether to start processing emails
start_processing_emails = False
# Iterate through the lines of the file
for line in lines:
# Check if the line starts with 'Subject:'
if line.startswith('Subject:'):
# Extract the subject from the line
subject = line[len('Subject:'):].strip()
# Check if the line is 'EMAILS:'
elif line.strip() == 'EMAIL:':
# Set flag to start processing emails
start_processing_emails = True
# Continue only if flag is set and line is not empty
elif start_processing_emails and line.strip():
# Append non-empty lines to the email content
email_content += line
# Construct the email content
text = f"Subject: {subject}\n\n{email_content}"
# Send the email
server.sendmail(email, send_to_email, text)
# Close the SMTP server connection
server.quit()