import smtplib
      
      my_email = "sigmapython88@gmail.com"
      password = "bjorn123"
      
      with smtplib.SMTP("smtp.gmail.com", port=587) as connection:
        connection.starttls()
        connection.login(user=my_email, password=password)
        connection.sendmail(from_addr=my_email, to_addrs="bjornseo@gmail.com",
                  msg="Subject:Hello\n\nThis is the body of the email")
        connection.close()

      Python language logo
      send email

      The code begins by creating an instance of the SMTP object. Then, it sets up the necessary parameters, including the hostname (smtp.gmail.com) and port number (587). It also sets up the authentication credentials for the user (my_email and password) and finally sends the email. Finally, it closes the SMTP connection.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.