welcome everybody ππ
Today I will share with you How to send email using python
step 1
you need to choice Mail Service Provider
like yahoo, gmail, aol
this is list of 10 Best FREE Email Account: Mail Service Providers (2023 List)
choice one of them π€
step 2
In this step you need to go to your account
To generate an application password or set the settings according to the service
if you useing aol or yahoo you will make the Same settings
Because they are similar to each other
Go to your account
Then select "security".
Scroll down the page
Even the "ACCOUNT ACCESS" section
"
Click on Generate app password
Click Get started
Choose the name of the application
Copy the password
step 3
you need to kenow 2 things 1 - SMTP server name 2 - SMTP server port of your Mail Service Provider
for example aol
AOL SMTP server name: smtp.aol.com
AOL SMTP username: your AOL address
AOL SMTP password: your account password
AOL SMTP port: 25 or 465
Note!
i used port : 587 instead of 465 Because port 465 is not working
The same idea on all Mail Service Provider's
Use Google to find this info or use Google bard
step 4
you need an email to receive the message
you can use temp-mail
step 5
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
msg = MIMEMultipart()
msg['From'] = 'your email'
msg['To'] = 'receiver email'
msg['Subject'] = 'Test ;)'
html = """
<h1>Hi, This is test π</h1>
"""
msg.attach(MIMEText(html, 'html'))
msg_str = msg.as_string()
server = smtplib.SMTP('smtp.aol.com', 587)
server.starttls()
server.ehlo()
server.login('email username', 'your password')
server.send_message(msg)
Now we're done π€
Don't forget to like and follow π
Support me on PayPal π€
https://www.paypal.com/paypalme/amr396