I am using IMAPClient library for fetching emails. In my application i have multiple options where i have to always create a socket connection or login to email account using IMAPClient.
- Read mail
- Fetch mail
- Fetch folders etc
For each options my application has to create a connection with email account using IMAPClient
which consume time.
Is there any way where i can only create a connection one time and same connection i can reuse to perform other activities whenever required.
Sample code example
from imapclient import IMAPClient
email_address = "emailid"
password = "password"
imap_server = 'imap.gmail.com'
mail_server = IMAPClient(imap_server, use_uid=True, ssl=True)
mail_server.login(email_address, password)
I want to store this mail_server
ssl socket object and reuse whenever needed.