mattia95 Posted August 31, 2018 Share Posted August 31, 2018 Hi!I'm trying to run this python code on tommy: import imaplibimport email mail = imaplib.IMAP4_SSL('imap.gmail.com')mail.login('myaccount@gmail.com', 'mypwd')x,y=mail.status('INBOX','(MESSAGES UNSEEN)')messages=int(re.search('MESSAGES\s+(\d+)',y[0]).group(1))unseen=int(re.search('UNSEEN\s+(\d+)',y[0]).group(1))print messagesprint unseen It doesn't execute it because it doen't print anything. Can you help me?Simpler codes with only a print execute well Quote Link to comment Share on other sites More sharing options...
wolstech Posted August 31, 2018 Share Posted August 31, 2018 Gmail is a known issue, and it's to do with Google's security. It doesn't like being accessed because of its security requirements. You need to do a few things... First, make sure you go in your Google settings and turn on the "Allow less secure applications to access your account" option. With this setting turned off, the only apps that work are the gmail website and cell phones. Even Microsoft Outlook requires that setting be turned on... After that, you need to write your Python to use SSL for IMAP and access their server on port 993. I don't know how to do this step in Python, so you'll need to refer to the documentation for that. Quote Link to comment Share on other sites More sharing options...
mattia95 Posted August 31, 2018 Author Share Posted August 31, 2018 Thank you very much! I found out that my code works with another email address so it's sure that the problem depended on Google. I'll try with my gmail address following your tips. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.