-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathemailing.py
More file actions
35 lines (27 loc) · 848 Bytes
/
Copy pathemailing.py
File metadata and controls
35 lines (27 loc) · 848 Bytes
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
import smtplib
import os
from dotenv import load_dotenv
from pathlib import Path
from email.message import EmailMessage
dotenv_path = Path("./.env")
load_dotenv(dotenv_path=dotenv_path)
PASSWORD = os.getenv("PASSWORD")
# Create SMTP session
s = smtplib.SMTP("smtp.gmail.com", 587)
# Start TLS for security
s.starttls()
# Authentication
EMAIL_ADDRESS = "no.reply.result.update@gmail.com" # Replace with your email address
s.login(EMAIL_ADDRESS, PASSWORD)
# Create an EmailMessage object
msg = EmailMessage()
msg["From"] = EMAIL_ADDRESS
msg["To"] = "ishpuneetsingh6@gmail.com" # Replace with the recipient's email address
msg["Subject"] = "Result Update" # Add the subject to the email
# Set the email body
msg.set_content("Hello")
# Sending the email
s.send_message(msg)
print("Email sent successfully!")
# Terminate the session
s.quit()