Skip to main content

Command Palette

Search for a command to run...

How to send emails using python

Updated
2 min read
H

Hi, I’m Happiness Omale, a Developer Relations Advocate, Data Scientist, and Technical Writer passionate about making AI/ML tools feel less intimidating and more useful.

In the past year alone:

  • I led a 3-week community campaign that grew WTM Lagos online engagement by 40%.
  • Wrote and published 15+ technical articles on Python, Data Science, Machine Learning, and AI tools crafted to drive clarity, adoption, and trust.
  • Hosted a Developer vs Designer X AMA that brought in 30+ live listeners and sparked meaningful conversation across our community.

I recently completed a hands-on DevRel training at DxMentorship (Cohort 4), where I deepened my skills in developer advocacy, technical storytelling, product documentation, and community engagement. It gave me the tools and confidence to take on real-world DevRel challenges and the clarity that this is exactly the space I want to grow in.

Whether I’m creating a YouTube tutorial, writing documentation, or hosting a Twitter Space, I thrive at the intersection of tech, storytelling, and community.

I explore emerging AI/ML tools and create demo videos for them on my YouTube channel, "Code & Content with Happiness", helping developers and creators learn faster. I enjoy translating product features into relatable, actionable insights for developers, especially those just getting started.

Right now, I’m looking to join an AI or ML-focused company as a Developer Advocate, somewhere I can drive education, grow communities, and create content that brings real value to users.

Let’s connect if you're building something great and need someone to help developers fall in love with it.

What are emails? Emails are messages distributed by electronic means from one computer user to another. There can be many more recipient as well via network.

Methods we can use to send an email:

  1. We can use python web automation using selenium.
  2. We have a python library which is SMTP library which can be used to send an email. But for this article I shall be explaining how to use the STMP library. STMP which means simple transfer mail protocol. STMP library, this library or the modules defines an SMTP clients session object which can be used to send an email to any other internet machine with an STMP or E-STMP listener daemon.

    Here's the full code

           :
           import smtplib
           server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
           server.login('example@gmail.com', 'password')
           server.sendmail('example@gmail.com', 
           'contact1@gmail.com', 'Hi happiness,how are you?')
           server.quit()
    

Quickly what you should note: "example@gmail.com"-your email address should be there "password"-the password to your email address "contact1@gmail.com"-the receiver's email address. then you go ahead with the body of the message.

So here's the output gmail ans.JPG

Finally you have to enable your "less secure app" from your google account in order to send the message.