How it works
Integrate Mailtrap into your Apache Airflow environment to programmatically author and monitor email delivery within your data pipelines. Using the official airflow-provider-mailtrap package, you can define email steps as tasks within your Directed Acyclic Graphs (DAGs) using the MailtrapSendEmailOperator. This allows your workflows to automatically distribute data exports, notify stakeholders of completed tasks, or alert engineers to pipeline failures via the Mailtrap Email API.

Configure
Step 1: Create a Mailtrap account, verify your sending domain, and generate an API Token with admin access.
Step 2: Ensure you are running Python 3.9+ and Apache Airflow 2.4+.
Step 3: Run this command in your Airflow environment:
pip install airflow-provider-mailtrap
Step 4: In the Airflow UI, navigate to Admin → Connections and add a new record:
- Connection ID:
mailtrap_default - Connection Type:
mailtrap - API Token: Your Mailtrap API Token
- Extra (Optional): Set a default sender address in JSON format.
Step 5: Import and add the MailtrapSendEmailOperator to your DAG code.
For detailed guidance, consult the knowledge base article.
Use cases
- Automatically trigger internal notifications or system alerts.
- Automate reports or data exports directly from your data processing pipeline.
- Send context-aware messages, such as user onboarding emails or password resets, triggered by complex logic within your Airflow workflows.
Supported functionality
- Send emails directly from your DAGs using native Airflow patterns.
- Configure your credentials once via Airflow Connections without the need for writing or maintaining custom email-sending code across multiple pipelines.
- Get detailed delivery insights and analytics via the Mailtrap dashboard, and have deeper visibility into email performance that extends beyond standard Airflow logs.