![]() |
IMAPLib Has No Attribute IMAP4_SSL. Help! - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: IMAPLib Has No Attribute IMAP4_SSL. Help! (/thread-27584.html) |
IMAPLib Has No Attribute IMAP4_SSL. Help! - bmccollum - Jun-12-2020 I've written a Python script that checks an email address on an Exchange server once per minute to check for new emails, download those emails as individual text files, then turn around and parse thru each of those individual text files to scrape desired info. from the emails and insert the data into Oracle. The script has worked perfectly fine on my development box for months as it's undergone development. I'm hitting a major road block now that I've tried to compile the script to an EXE (using PyInstaller) and execute it in various environments (INT / QA / PROD) in testing out the functionality. Below is a very scaled down snippet of the basic lines that take care of establishing a connection to the email server and logging the desired email inbox: import imaplib def open_connection(verbose=False): try: # Connect to the server connection = imaplib.IMAP4_SSL('someserver.somedomain.com',993) # Login to our account connection.login("username", "password") return connection except Exception as e: print ("Email login connection error: " + str(e)) return 'Failed' print (open_connection())The error message I'm getting back from trying to run the compiled EXE on any other machine beyond the development machine is:
I've racked my brain extensively on this, have researched possible fixes & solutions, have tried switching out the IMAPLib to POP3 instead, with all of these various ways of establishing a connection being successful until I use PyInstaller to compile the native .py script to a self-executing EXE, and then these EXEs don't work on other computers. For example, when I change the server/email access protocol from IMAPLib to POP3, then I receive a similar error message as the one with IMAPLib:
I'd sincerely appreciate any recommendations at all on this. Thanks in advance. RE: IMAPLib Has No Attribute IMAP4_SSL. Help! - bmccollum - Jun-12-2020 So I changed things up just slightly, and this exchange server / email inbox access code now performs fine outside of my development environment. Code is now as follows: from imaplib import IMAP4 def open_connection(verbose=False): try: # Connect to the server connection = IMAP4('someserver.somedomain.com') # Login to our account connection.login("username", "password") return connection except Exception as e: print ("Email login connection error: " + str(e)) return 'Failed' print (open_connection()) RE: IMAPLib Has No Attribute IMAP4_SSL. Help! - Larz60+ - Jun-13-2020 I looked at the documentation for this package (what there is of it). I was written for python 2.7. The repository was moved to a python 3 GitHub repository, but appears to be in limbo with last change made back in 2017. I'd find another package that does what you need (look at https://pypi.org/search/?q=IMAP4&o=-zscore ) I can't recommend any one of these packages as I haven't used them, so you will probably have to try one or two to get one that meets your specs. The listing in the link above in in trending order. RE: IMAPLib Has No Attribute IMAP4_SSL. Help! - bmccollum - Jun-13-2020 Thanks very much for the link. I'll check out the other packages that are mentioned in that link and will try them out. |