# Path: imap_tools/mailbox.py
# class MailBox(BaseMailBox):
#     """Working with the email box through IMAP4 over SSL connection"""
# 
#     def __init__(self, host='', port=993, timeout=None, keyfile=None, certfile=None, ssl_context=None):
#         """
#         :param host: host's name (default: localhost)
#         :param port: port number
#         :param timeout: timeout in seconds for the connection attempt, since python 3.9
#         :param keyfile: PEM formatted file that contains your private key (deprecated)
#         :param certfile: PEM formatted certificate chain file (deprecated)
#         :param ssl_context: SSLContext object that contains your certificate chain and private key
#         """
#         check_timeout_arg_support(timeout)
#         self._host = host
#         self._port = port
#         self._timeout = timeout
#         self._keyfile = keyfile
#         self._certfile = certfile
#         self._ssl_context = ssl_context
#         super().__init__()
# 
#     def _get_mailbox_client(self) -> imaplib.IMAP4:
#         if PYTHON_VERSION_MINOR < 9:
#             return imaplib.IMAP4_SSL(self._host, self._port, self._keyfile, self._certfile, self._ssl_context)
#         else:
#             return imaplib.IMAP4_SSL(self._host, self._port, self._keyfile, self._certfile, self._ssl_context,
#                                      self._timeout)


import email
from imap_tools import MailBox
"""
Email modification is not common case operation
Most likely it will not be added to lib

Also, I have tried to add public attribute - MailMessage.orig_bytes (raw_message_data)
But it have increased memory consumption: ~10%
"""



# Path: imap_tools/mailbox.py
# class MailBox(BaseMailBox):
#     """Working with the email box through IMAP4 over SSL connection"""
# 
#     def __init__(self, host='', port=993, timeout=None, keyfile=None, certfile=None, ssl_context=None):
#         """
#         :param host: host's name (default: localhost)
#         :param port: port number
#         :param timeout: timeout in seconds for the connection attempt, since python 3.9
#         :param keyfile: PEM formatted file that contains your private key (deprecated)
#         :param certfile: PEM formatted certificate chain file (deprecated)
#         :param ssl_context: SSLContext object that contains your certificate chain and private key
#         """
#         check_timeout_arg_support(timeout)
#         self._host = host
#         self._port = port
#         self._timeout = timeout
#         self._keyfile = keyfile
#         self._certfile = certfile
#         self._ssl_context = ssl_context
#         super().__init__()
# 
#     def _get_mailbox_client(self) -> imaplib.IMAP4:
#         if PYTHON_VERSION_MINOR < 9:
#             return imaplib.IMAP4_SSL(self._host, self._port, self._keyfile, self._certfile, self._ssl_context)
#         else:
#             return imaplib.IMAP4_SSL(self._host, self._port, self._keyfile, self._certfile, self._ssl_context,
#                                      self._timeout)


# Path: examples/edit_email.py
import email
from imap_tools import MailBox

"""
Email modification is not common case operation
Most likely it will not be added to lib

Also, I have tried to add public attribute - MailMessage.orig_bytes (raw_message_data)
But it have increased memory consumption: ~10%
"""



with MailBox('imap.mail.com').login('test@mail.com', 'password') as mailbox: