How to Extract Emails from Mailgun Logs and Events
On this page
Export and import options vary by plan, permissions and product version. Check the platform’s current help documentation if a menu or format differs. Use only contact data you are authorized to process; an extracted address is not proof of marketing consent.
Why Extract from Mailgun?
Mailgun is a transactional email API service for developers. It provides email sending, receiving, validation, routing, tracking, analytics and logs. Mailgun stores logs of every email sent and received through the platform, including recipient and sender email addresses.
Extracting email addresses from Mailgun data is useful for building a list of all recipients your application has emailed, identifying active contacts from delivery events, consolidating email contacts across services, auditing email traffic or creating a backup.
How to Export from Mailgun
Exporting from the dashboard
- Log in to Mailgun.
- Go to Sending then Logs (or Events).
- Filter by date range, event type (delivered, opened, clicked, bounced, etc.) and domain.
- Export the logs as CSV.
- The CSV includes recipient email, event type, timestamp, subject and message ID.
Exporting suppression lists
- Go to Sending then Suppressions.
- Export bounces, complaints or unsubscribes as CSV.
- These lists contain the email addresses that should not be contacted.
Exporting mailing lists
- Go to Sending then Mailing Lists (if you use Mailgun mailing lists).
- Export the list members as CSV.
Using the API
Mailgun's Events API allows programmatic access to event data. Export events to a file using the API for larger datasets.
How to Extract the Email Addresses
- Go to bulkemailextractor.com.
- Select "Text and files."
- Upload the CSV file exported from Mailgun. Up to 25 MB per file, 100 MB per batch.
- Click "Extract emails."
- Review the results. Duplicates are removed automatically.
- Download as TXT for a plain list, CSV for a single-column spreadsheet, or CSV with sources.
Working with the Results
Audit your recipient list
Extract all recipient email addresses from delivery logs to see who your application has been emailing. This is useful for compliance audits and understanding your total reach.
Build a suppression list
Extract emails from bounce and complaint logs. Import this suppression list into other email platforms to avoid sending to known bad addresses.
Identify engaged contacts
Export only logs with "opened" or "clicked" events. Extract emails from these to build a list of engaged recipients for targeted campaigns.
Verify addresses
Emails from delivery logs represent actual sending attempts. Some may have bounced or become invalid. Cross-reference with suppression lists and verify before re-use. See Best email verification services.
Things to Know
Contact data is not preserved
Email Extractor outputs email addresses only. Event types, timestamps, subjects, message IDs and other log fields are not carried over.
Sender and recipient emails
Mailgun logs include both sender and recipient email addresses. Both will appear in extraction results. Remove your own sending addresses from the final list.
Log retention
Mailgun retains log data for a limited period depending on your plan. Export data before it expires.
Transactional vs marketing
Mailgun is primarily used for transactional emails (password resets, order confirmations, notifications). The recipient list from Mailgun reflects your application's user base, not necessarily a marketing-consented list.
Multiple domains
If you send from multiple domains through Mailgun, export logs for each domain separately or together.
Suppression lists are critical
Before using extracted recipient emails for any outreach, cross-check against your Mailgun suppression lists (bounces, complaints, unsubscribes). These addresses should be excluded.
Mailgun Optimize
Mailgun Optimize provides email validation and deliverability tools. It is separate from the transactional sending service.