Solution: How to send email using a python follow up this

Solution: How to send email using a python follow up this

# Step One Setup Your App Password For this url {https://accounts.zoho.in/home#security/app_password}
# Step Two copy Password For Generate time replace this YOUR_APP_PASSWORD

# Run this file example - python main.py

# Chake Your Terminal Show this message Email sent successfully!

import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

# Zoho Mail credentials
sender_email = "mrmishrajee@zohomail.in"
password = "YOUR_APP_PASSWORD"  # ⚠️ Use app password, not your normal login password
receiver_email = "sunilmishra810133@gmail.com"

# Create the email
msg = MIMEMultipart()
msg["From"] = sender_email
msg["To"] = receiver_email
msg["Subject"] = "Test Email from Python via Zoho Mail"

# Email body
body = """\
Hi Sunil,

This is a test email sent from Python using Zoho Mail SMTP server.

Best regards,  
Mr. Mishra
"""

msg.attach(MIMEText(body, "plain"))

# Send the email
try:
    with smtplib.SMTP_SSL("smtp.zoho.in", 465) as server:
        server.login(sender_email, password)
        server.sendmail(sender_email, receiver_email, msg.as_string())
        print("✅ Email sent successfully!")
except Exception as e:
    print(f"❌ Error: {e}")