-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact.py
32 lines (24 loc) · 821 Bytes
/
contact.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
import smtplib
def send_email(subject, body, to_email):
# Email configuration
sender_email = 'contact.od.terminal@gmail.com'
sender_password = 'iwbl hrck qnad thmo'
smtp_server = 'smtp.gmail.com'
smtp_port = 587
# Create email headers
headers = f"Subject: {subject}\nFrom: {sender_email}\nTo: {to_email}\n"
# Connect to the SMTP server
server = smtplib.SMTP(smtp_server, smtp_port)
server.starttls()
# Login to the email account
server.login(sender_email, sender_password)
# Send email
server.sendmail(sender_email, to_email, headers + '\n' + body)
# Quit the server
server.quit()
# Example usage
'''subject = 'Test Email'
body = 'This is a test email sent from Python.'
to_email = 'sakshamraghav57@gmail.com'
send_email(subject, body, to_email)
'''