Quantcast
Viewing all articles
Browse latest Browse all 14215

What is wrong with the following code for sending a verification email?

the output gets to "STAGE 1" but after that it comes up with a bunch of errors. The tutorial im using is here: https://www.youtube.com/watch?v=g_j6ILT-X0k

    def send_email():        print("send_email function")        email_sender = *hidden        email_password = *hidden        email_receiver = new_email        print(new_email)        print(code)        subject = "Verification Code"        body = """Your Verification code is: """+code        print(body)        em = EmailMessage()        em["From"] = email_sender        em["To"] = email_receiver        em["Subject"] = subject        em.set_content(body)        context = ssl.create_default_context()        print("STAGE 1")        with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as smtp:            smtp.login(email_sender, email_password)            print("STAGE 2")            smtp.sendmail(email_sender, email_receiver, em.as_string())            print("STAGE 3")

ran through chatgpt, but nothing.The error is "No connection made because the target machine actively refuses it"


Viewing all articles
Browse latest Browse all 14215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>