Python Send Emails

python day 30

Can you believe we can use Python to send emails?📩

To my surprise, it actually works! 😜

So today Iet’s try to send an email from gmail using python with
“Yibo asks you to play the skateboard” 🙈🙈🙈🙈🙈

  • Module: email, smtplib 

✨ Trick: Turn ON Gmail less secure pass

Python Code:

import email
import smtplib

msg = email.message_from_string('Yibo asks you to play the skateboard')
msg['From'] = ""
msg['To'] = ""
msg['Subject'] = "Hola hola"

s = smtplib.SMTP("",587)
s.ehlo() # Hostname to send for this command defaults to the fully qualified domain name of the local host.
s.starttls() #Puts connection to SMTP server in TLS mode
s.login('', 'iloveu')

s.sendmail("", "",  msg.as_string())


You’ve got a mail:


Happy Studying! I’m going to go skateboarding now !!!

Note: I didn’t try Hotmail or other mails, please let me know if it works.



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social media & sharing icons powered by UltimatelySocial
%d bloggers like this: