forked from MSU-AI/shopping-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
29 lines (26 loc) · 983 Bytes
/
test.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
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
# Replace these with your details
your_email = '[email protected]'
your_app_password = 'ljeghppuzyixrmeg' # Use your app-specific password here
recipient_email = '[email protected]'
# Create the MIME message
msg = MIMEMultipart()
msg['From'] = your_email
msg['To'] = recipient_email
msg['Subject'] = 'Test Email from Python'
body = 'This is a test email sent from a Python script using Yahoo SMTP.'
msg.attach(MIMEText(body, 'plain'))
# Send the email
try:
server = smtplib.SMTP('smtp.mail.yahoo.com', 587)
server.set_debuglevel(1) # Enable debug output to see the communication with the server
server.starttls()
server.login(your_email, your_app_password)
text = msg.as_string()
server.sendmail(your_email, recipient_email, text)
server.quit()
print("Email sent successfully!")
except Exception as e:
print(f"Failed to send email: {e}")