#SENDS MAIL WITH MESSAGE HELLO
def send_email():
import smtplib
server = smtplib.SMTP(‘smtp.gmail.com’, 587)
server.ehlo()
server.starttls()
server.ehlo()
#Next, log in to the server
server.login(‘[email protected]’, ‘password’)
#Send the mail
msg = “nHello!” # The /n separates the message from the headers
server.sendmail(“[email protected]”, “[email protected]”, msg)
send_email();
NOTES
FOR FIRST TIME YOU WILL GET ERROR MESSAGE AS IN BELOW
“Blocked sign-in attempt for security reasons”
GIVE ALLOW ACCESS. THEN RESEND THE MESSAGE ONCE MORE