Question:
So i am following the “20 Beginner Projects” from freeCodeCamp, as such i tried to write the code first and only when i am stuck to use the help from the video.
Well i finished my email_sender-code (i checked it 4 times with the code from the video) yet i always get the error g.mail didin’t accept my “email_sender” and “email_password” variables and sadly the video couldn’t answer my issue.
I tried looking in the library but got confused in the end .
I purposefully left the “email_sender” and “email_password” empty, both contain letters and numbers, i firs thought that that is the issue, but shouldn’t the numbers still be written n correctly.
Repl link:
https://replit.com/@CA4334/emailsender#main.py
code snippet
Error message:
Traceback (most recent call last):
File “c:\Users\Azatg\OneDrive\Desktop\Phyton-Programme\Email_Sender.py”, line 34, in
smtp.login(email_sender, email_password)
File “C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\smtplib.py”, line 750, in login
raise last_exception
File “C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\smtplib.py”, line 739, in login
(code, resp) = self.auth(
File “C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\smtplib.py”, line 662, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b’5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https:// support .google .com/mail/?p=BadCredentials j4-20020aa7c0c4000000b004847513929csm11835908edp.72 - gsmtp’)
code line that is the issue:
with smtplib.SMTP_SSL(“smtp.gmail. com”, 465, context = context) as smtp:
__smtp.login(email_sender, email_password)
__smtp.sendmail(email_sender, email_receiver, em.as_string())