sending an email from python code example
Example 1: email in python
#>>>>>>>>>>>>>>>>>>> GIVE AN UP VOTE IF YOU LIKED IT <<<<<<<<<<<<<<<<<<<<<
#Easiest and Readable way to Email
#through Python SMTPLIB library
#This works with >>> Gmail.com <<<
import smtplib
from email.message import EmailMessage
EmailAdd = "Email id" #senders Gmail id over here
Pass = "Email Password" #senders Gmail's Password over here
msg = EmailMessage()
msg['Subject'] = 'Subject of the Email' # Subject of Email
msg['From'] = EmailAdd
msg['To'] = '[email protected]','[email protected]' # Reciver of the Mail
msg.set_content('Mail Body') # Email body or Content
#### >> Code from here will send the message << ####
with smtplib.SMTP_SSL('smtp.gmail.com',465) as smtp: #Added Gmails SMTP Server
smtp.login(EmailAdd,Pass) #This command Login SMTP Library using your GMAIL
smtp.send_message(msg) #This Sends the message
Example 2: how to send email with python
import smtplib, ssl
port = 465 # For SSL
password = input("Type your password and press enter: ")
# Create a secure SSL context
context = ssl.create_default_context()
with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server:
server.login("[email protected]", password)
# TODO: Send email here