DEV Community

Omale Happiness Ojone
Omale Happiness Ojone

Posted on

How to send emails using python

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('', 465)
          server.login('', 'password')
          '', 'Hi happiness,how are you?')

Quickly what you should note:
""-your email address should be there
"password"-the password to your email address
""-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.

Top comments (0)