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

      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 ( 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.


        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.