-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathemails.py
25 lines (23 loc) · 1017 Bytes
/
emails.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
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def send_email(candidate_email):
# Email configuration
sender_email = '[email protected]' # sender email address
password = 'your_password' # sender email password
subject = 'Thank you for your submission'
message = 'Dear Candidate, \n\nThank you for submitting your application. Our system shall review it carefully and revert to you within 1 working day.\n\nBest regards,\n Team automatic'
msg = MIMEMultipart()
msg['From'] = sender_email
msg['To'] = candidate_email
msg['Subject'] = subject
msg.attach(MIMEText(message, 'plain'))
try:
server = smtplib.SMTP('smtp.gmail.com', 587) # Replace with your SMTP server and port
server.starttls()
server.login(sender_email, password)
server.send_message(msg)
server.quit()
print("Email sent successfully!")
except Exception as e:
print(f"Error: {e}")