IMAP_RETURN_STATUS
IMAPMailToolkit
- Fetching emails with filtering options
- Retrieving specific emails by ID
- Sending emails via SMTP
- Replying to emails
- Moving emails to folders
- Deleting emails
- imap_server (str, optional): IMAP server hostname. If not provided, will be obtained from environment variables.
- imap_port (int, optional): IMAP server port. Defaults to 993. (default: 993)
- smtp_server (str, optional): SMTP server hostname. If not provided, will be obtained from environment variables.
- smtp_port (int, optional): SMTP server port. Defaults to 587. (default: 587)
- username (str, optional): Email username. If not provided, will be obtained from environment variables.
- password (str, optional): Email password. If not provided, will be obtained from environment variables.
- timeout (Optional[float]): The timeout for the toolkit operations.
- connection_idle_timeout (float): Maximum idle time (in seconds) before auto-closing connections. Defaults to 300 (5 minutes).
init
- imap_server: IMAP server hostname (default: :obj:
None) - imap_port: IMAP server port (default: :obj:
993) (default: 993) - smtp_server: SMTP server hostname (default: :obj:
None) - smtp_port: SMTP server port (default: :obj:
587) (default: 587) - username: Email username (default: :obj:
None) - password: Email password (default: :obj:
None) - timeout: Timeout for operations (default: :obj:
None) - connection_idle_timeout: Max idle time before auto-close (default: :obj:
300seconds)
_get_imap_connection
_get_smtp_connection
_ensure_imap_ok
fetch_emails
- folder (
Literal["INBOX"]): Email folder to search in (default: :obj:"INBOX") - limit (int): Maximum number of emails to retrieve (default: :obj:
10) - unread_only (bool): If True, only fetch unread emails (default: :obj:
False) - sender_filter (str, optional): Filter emails by sender email address (default: :obj:
None) - subject_filter (str, optional): Filter emails by subject content (default: :obj:
None)
get_email_by_id
- email_id (str): ID of the email to retrieve
- folder (
Literal["INBOX"]): Folder containing the email (default: :obj:"INBOX")
send_email
- to_recipients (List[str]): List of recipient email addresses
- subject (str): Email subject line
- body (str): Plain text email body
- cc_recipients (List[str], optional): List of CC recipient email addresses
- bcc_recipients (List[str], optional): List of BCC recipient email addresses
- html_body (str, optional): HTML version of email body
- extra_headers (Dict[str, str], optional): Additional email headers
reply_to_email
- original_email_id (str): ID of the email to reply to
- reply_body (str): Reply message body
- folder (
Literal["INBOX"]): Folder containing the original email (default: :obj:"INBOX") - html_body (str, optional): HTML version of reply body (default: :obj:
None)
move_email_to_folder
- email_id (str): ID of the email to move
- target_folder (str): Destination folder name
- source_folder (
Literal["INBOX"]): Source folder name (default: :obj:"INBOX")
delete_email
- email_id (str): ID of the email to delete
- folder (
Literal["INBOX"]): Folder containing the email (default: :obj:"INBOX") - permanent (bool): If True, permanently delete the email (default: :obj:
False)
_extract_email_body
- email_message: Email message object
close
del
enter
exit
- exc_type: Exception type if an exception occurred
- exc_val: Exception value if an exception occurred
- exc_tb: Exception traceback if an exception occurred