I have a Python script that connects to Gmail using IMAP, which works perfectly in my local development environment in Visual Studio. However, when I try to run the same script on a hosting service (such as Namecheap), I encounter a network connectivity error.
The specific error I get is: OSError: [Errno 101] Network is unreachable.
Here's a simplified version of my code (with sensitive details removed):
import imaplib
# Connect to Gmail IMAP server
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login('[email protected]', 'mypassword')
# ... rest of the code ...