In this program, we take a look at how to send an Email using your Yahoo! Email using the Python SMTP library.
Program:import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# Email configuration
smtp_yahoo_server = 'smtp.mail.yahoo.com'
smtp_yahoo_port = 587
sender_email = 'your_yahoo_email@yahoo.com'
sender_password = 'your_yahoo_mail_password'
receiver_email = 'recipient@example.com'
email_subject = 'Email Using Python Code'
email_body = 'Hello, this is an email body test!'
# Multipart message
multipart_msg = MIMEMultipart()
multipart_msg['From'] = sender_email
multipart_msg['To'] = receiver_email
multipart_msg['Subject'] = email_body
# Sending email
multipart_msg.attach(MIMEText(multipart_msg, 'plain'))
smtp = smtplib.SMTP(smtp_yahoo_server, smtp_yahoo_port)
smtp.starttls()
smtp.login(sender_email, sender_password)
smtp.sendmail(sender_email, receiver_email, multipart_msg.as_string())
smtp.quit()
Read More: smtplib — SMTP protocol client
-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Python-Programs,
- Program 5: Find Sum of Two Integer Numbers - 1000+ Python Programs
- Program 8: Multiply Two Numbers - 1000+ Python Programs
- Python Program: Use NumPy to generate a random number between 0 and 1
- 25: How to rename a file using Python Program
- 22: Send Yahoo! Email using smtplib - SMTP protocol client using Python Program
- Program 15: Find String is a Palindrome or Not - 1000+ Python Programs
- 21: Program to Delete File or Folder in Python
- Program 14: Sum of Even Numbers from 1 to 100 - 1000+ Python Programs
- Program 2: Print your name using print() function - 1000+ Python Programs
- 20 - Python - Print Colors for Text in Terminal - 1000+ Python Programs
- 16: Find the largest element in a List - 1000+ Python Programs
- 33: Python Program to find the current time in India (IST)
- 23: Python Programs to concatenate two Lists
- 27: Measure Elapsed Time for a Python Program Execution
- 18: Get Sub List By Slicing a Python List - 1000+ Python Programs
- Program 10: Modulo of Two Numbers - 1000+ Python Programs
- Program 1: Print Hello World! - 1000+ Python Programs
- Program 11: Calculate Percentage - 1000+ Python Programs
- Program 12: Calculate Area and Circumference of Circle - 1000+ Python Programs
- 17: Find Factorial of a Number - 1000+ Python Programs
- 35: Python Program to find the System Hostname
- 19: Simple Calculator using built-in functions - 1000+ Python Programs
- 34: Traverse a List in Reverse Order - 1000+ Python Programming
- Program 3: Print the name of user as input - 1000+ Python Programs
- Program 9: Divide Two Numbers - 1000+ Python Programs
More Posts:
- Install Gradle VS Code for Java Projects - Gradle
- Fix - bash: man: command not found - Linux
- Tomcat Manager Default Username and Password - Tomcat
- Create Symbolic Link using Terminal Command - MacOS
- Create Duplicate Line Visual Studio Code (above or below) Example - HowTos
- Stop a Running Command on macOS Terminal - MacOS
- List of Code Snippets/Templates to Eclipse IDE - Eclipse
- Perform Basic Authentication using cURL with Examples - cURL