The Apache Airflow IMAP Provider enables Airflow to interact with IMAP email servers. It provides hooks and operators for tasks such as retrieving email attachments. The current version is 3.11.1 and it follows the release cadence of Apache Airflow providers, which are released regularly to support new Airflow features and address bug fixes.
pip install apache-airflow-providers-imapVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use the `IMAPRetrieveAttachmentOperator` to fetch a PDF attachment from an IMAP email server. It assumes an Airflow connection named 'imap_default' is configured with the necessary IMAP server credentials. The operator filters emails by sender, subject, and retrieves only unseen emails matching a regex pattern for the attachment name, saving it to a specified directory.
Verify all IMAP connection parameters in the Airflow UI. Ensure the IMAP server is accessible from Airflow workers and SSL/TLS settings match the server requirements.
Ensure the target directory exists on the Airflow worker's filesystem and has appropriate write permissions. You may need a preceding task to create the directory (`mkdir -p`) if it's not guaranteed to exist.
Carefully test your `email_filter` (e.g., FROM, SUBJECT, UNSEEN) and `attachment_name` regex with known test emails. Start with simple filters and gradually increase complexity. Use `check_regex=True` when `attachment_name` is a regex.
Ensure `apache-airflow-providers-imap` is installed in your Airflow environment. You can install it using pip: `pip install apache-airflow-providers-imap`.
Ensure `apache-airflow-providers-imap` is installed in your Airflow environment. You can install it using `pip install apache-airflow-providers-imap`.