Properly formatted example for Python iMAP email access?

前端 未结 4 1937
故里飘歌
故里飘歌 2021-02-01 09:57

tldr: Can someone show me how to properly format this Python iMAP example so it works?

from https://docs.python.org/2.4/lib/imap4-example.html

<         


        
4条回答
  •  北恋
    北恋 (楼主)
    2021-02-01 10:36

    Instead of M.login(getpass.getuser(email@gmail.com), getpass.getpass(password)) you need to use M.login('email@gmail.com', 'password'), i.e. plain strings (or better, variables containing them). Your attempt actually shouldn't have worked at all, since getpass's getuser doesn't take arguments but merely returns the user login name. And email@gmail.com isn't even a valid variable name (you didn't put it into quotes)...

提交回复
热议问题