1

I'm new to Python, and I'm doing this for work, so please explain like im 5 years old

I'm trying to login to my gmail account to automatically download all attachments.

I'm trying to initialize a connection but I get this:

see code and error here

edit:

see my gmail account settings here

Any help would be amazing. Thanks.

martineau
  • 119,623
  • 25
  • 170
  • 301
ye ye
  • 21
  • 5
  • https://support.google.com/mail/answer/7126229/check-gmail-through-other-email-platforms?hl=en#zippy=%2Ci-cant-sign-in-to-my-email-client may be helpful here if all other username/password settings line up. – Stephen Jun 10 '21 at 20:02
  • Google applies a large amount of security around IMAP use of accounts. They will not just allow you to log in to any account, as they consider it extremely sensitive. You will need to either enable “less secure apps” (dangerous, and doesn’t always work), or if your account uses 2FA, use google’s settings to generate a “app specific password”. Failing that, you will need to implement OAUTH2, which is complex and comes with legal requirements you need to agree to. – Max Jun 10 '21 at 20:33
  • 1
    See [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question) for reasons **not** to do it. – martineau Jun 10 '21 at 21:45
  • Does this answer your question? [reading gmail is failing with IMAP](https://stackoverflow.com/questions/33119667/reading-gmail-is-failing-with-imap) – Vladimir Jun 11 '21 at 05:42

2 Answers2

1

I named another project called 'email.py'. This ruined the 'import email' command.

I will use more apt names for my python projects now.

ye ye
  • 21
  • 5
-1

In my memories, I used SMTP lib to connect to Gmail, not IMAP. Also, you have to allow unverified app's to access to your Gmail account. You can do this in your Gmail's security settings. Once done, go at this URL : https://accounts.google.com/b/0/displayunlockcaptcha and complete the challenge. Then, launch your python script.

Ximaz
  • 198
  • 2
  • 9