Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29923

How can I send e-mails from python without having to enable less secure apps?

$
0
0

I am having trouble sending an e-mail without having to enable google's less secure apps: https://myaccount.google.com/lesssecureapps . How can I modify the code in Python so that I can send e-mail without having to enable this? I need to disable this option, because I am building an application in which the user can send a feedback e-mail to the developer, so I cannot force the user to enable less secure apps. My code in Python:

    def send_email(self):
        print("send e-mail to developer")
        sender_email = self.email.text
        sender_password = self.password.text
        sender_feedback = self.feedback_message.text
        print("email is: ", type(sender_email))
        print("pass is: ", sender_password)
        print("feedback message is: ", sender_feedback)

        server = smtplib.SMTP('smtp.gmail.com', 587)
        server.starttls()  # encrypt connection
        server.login(sender_email, sender_password)

        subject = 'Feedback'
        msg = sender_feedback

        msg = f"Subject: {subject} \n\n {msg}"
        server.sendmail(
            # from,to,message
            sender_email,
            'my_email@gmail.com',
            msg
        )
        print("E-MAIL HAS BEEN SENT!")
        server.quit()


Viewing all articles
Browse latest Browse all 29923

Trending Articles



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