code snippet:
#the if is for my use hehe
email = input("send help?")
if email ==1:
import smtplib
email = 'my@gmail.com' # Your email
password = 'mypass123' # Your email account password
send_to_email = 'her@gmail.com' # Who you are sending the message to
message = 'This is my message' # The message in the email
server = smtplib.SMTP('smtp.gmail.com', 587) # Connect to the server
server.starttls() # Use TLS
server.login(email, password) # Login to the email server
server.sendmail(email, send_to_email , message) # Send the email
server.quit() # Logout of the email server
the error:
Traceback (most recent call last)
File "main.py", line 97, in <module>
Server = smtplib.SMTP('my@gmail.com', 587)
Connect to the server
NameError: name 'smtplib' not defined
I wrote the error manually, but it’s exactly the same as the error message I received.
There used to be a Google Account feature called Less secure apps that allowed you to toggle between allowing secure and less secure apps. What you’re trying to do would be classified as “less secure”. However, Google recently removed support for less secure apps as you can see in the above image. This means that you won’t be able to log in to the account from your program and thus are unable to send emails with this method.
OH NOOOOOO is there any way to send email without SMTP? I’ve googled some of it, including google cloud console, loom, and else. But those are way too complicated. I’ve tried using google cloud console, but I got stuck with the redirect URL. I don’t understand what URL I should put it in.
And yes it still works, you have to use an App password since google removed Allow Access from Less Secure apps, just read through the readme I explained it there as well as how to get an app password