Python Forum
IMAPLib Has No Attribute IMAP4_SSL. Help!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IMAPLib Has No Attribute IMAP4_SSL. Help!
#1
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:
  • IMAPLib has no attribute IMAP4_SSL

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:
  • POPLib has no attribute POP3

I'd sincerely appreciate any recommendations at all on this. Thanks in advance.
Reply
#2
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())
Reply
#3
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.
Reply
#4
Thanks very much for the link. I'll check out the other packages that are mentioned in that link and will try them out.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Assistance debuging imaplib errors Linh_lee 1 1,043 Aug-21-2022, 05:57 PM
Last Post: Linh_lee
  imaplib problem levann 3 3,585 Jul-15-2019, 10:05 AM
Last Post: levann
  How can read and download the attachment from the mail using while loop in IMAPlib Py Samjith 0 4,272 Oct-11-2018, 07:15 AM
Last Post: Samjith
  Email Checker with IMAPlib ronaldrios 1 3,799 Jun-23-2017, 04:03 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020