tr Skip to content
Black Friday FlowMattic for life, 12 payments of $33.25 Or $399 once. Nothing added for splitting Ends in --Days --Hrs --Min --Sec See the deal

IMAP Email Automation in WordPress: Act on Every New Message

FlowMattic IMAP Email Parser: a new email in a connected mailbox starts a workflow that classifies it with an AI Agent, routes it to Slack and moves it to a folder.

IMAP email automation lets a workflow read a real mailbox. FlowMattic’s IMAP Email Parser connects to any account that speaks IMAP, starts a workflow when a new message arrives in the folder you choose, and gives you six actions to manage that message afterwards: import its attachments, mark it read or unread, flag it, or move it to another folder.

It suits teams whose work arrives by email in an inbox they already own: support@, invoices@, orders@ or a shared sales address. The mailbox stays where it is, and FlowMattic checks it from your WordPress site on the schedule you set.

What is the IMAP Email Parser?

IMAP Email Parser is a core FlowMattic app with four triggers and six actions. Mailbox accounts are added once in FlowMattic’s Settings and can then be used by any workflow. The connection uses a pure PHP implementation, so no IMAP extension is needed on the server, though the module does need PHP 8.1 or later.

If you would rather not connect a mailbox at all, the separate Email Parser gives each workflow an address to forward mail to. IMAP is the better fit when the workflow should also act on the mailbox itself.

Connect a mailbox

Open FlowMattic → Settings → IMAP Email and click Add IMAP Account. The form asks for:

  • Account Label: the name you’ll pick in workflows, such as “Acme support inbox”.
  • IMAP Host and Port: for example imap.gmail.com and the default 993.
  • Encryption: SSL (default), TLS or None.
  • Email / Username and Password: for Gmail, use an App Password instead of your regular password.
  • Validate SSL Certificate: off by default; leave it unchecked if you see certificate validation errors.

Click Test Connection to check the details, then Add Account.

FlowMattic Settings, IMAP Email section, showing the Add IMAP Account form with Account Label, IMAP Host, Port, Encryption, Email / Username and Password fields.
Add IMAP Account in FlowMattic Settings, with host, port, encryption, login and a Test Connection button.

How IMAP email automation works

Add a trigger, choose IMAP Email Parser and pick one of four events:

TriggerStarts a run whenExtra field
Email ReceivedA new email arrives in the folder.None
Email with Subject ContainsThe subject contains your text, ignoring case.Subject Filter
Email from Specific SenderThe sender’s address or name contains your text, ignoring case.Sender Email
Email with AttachmentThe email has at least one attachment.None

Every trigger also has Choose IMAP Account, Email Folder (INBOX by default, with a Refresh Folders link to load the rest), Mark as Read (“Automatically mark processed emails as read”) and Frequency, from 1 Minute to 1 Day with 10 Minutes as the default. Capture a response and the newest matching email becomes your sample data.

On each check, FlowMattic looks at unread messages in the folder from about the last day, newest first, and stops when it reaches the last email it processed. The newer ones run through the workflow one at a time, oldest first, so a burst of mail is handled in the order it arrived.

What each email gives you

  • Message: uid, message_id, subject, date, folder, priority
  • People: from_email, from_name, to, cc, reply_to
  • Body: body_text and body_html
  • Attachments: has_attachments, attachment_count and attachments, a list of each file’s name, size and type
  • Threading: in_reply_to and references
  • Forwarding: envelope_to, delivered_to, x_original_to and original_to, FlowMattic’s best guess at the address a forwarded message was first sent to

Actions that manage the mailbox

Each action takes Choose IMAP Account, the folder the email is in, and its Message UID, which you map from the trigger’s uid.

ActionWhat it does
Import Email Attachments to Media LibraryDownloads every attachment into the WordPress Media Library and returns media_1_id, media_1_url, media_1_name, media_1_type and so on for each file, plus total_attachments and imported_attachments.
Mark Email as ReadSets the message as seen.
Mark Email as UnreadSets it back to unseen, so it stays visible to the team.
Move Email to FolderMoves it from Source Folder to Target Folder. The target folder must already exist.
Flag Email (Mark as Important)Adds the flag or star.
Unflag Email (Remove Important)Removes it.
FlowMattic builder showing an IMAP Email with Attachment trigger followed by the Import Email Attachments to Media Library action with Message UID mapped from the trigger.
Import Email Attachments to Media Library takes the account, folder and the trigger's message UID.

Use cases

Support inbox sorted by AI

An AI Agent reads each new message and labels it as a support request, an invoice or a newsletter. A Router posts support requests to Slack with a summary and moves newsletters out of the inbox.

Email Received → AI Agent → Router → Slack · Move Email to Folder

Invoices filed without opening them

For an accounts mailbox, the attachment trigger picks up every bill. The files go to the Media Library, the PDF Parser reads the amount, and a WP Tables row records it with a link to the file.

Email with Attachment → Import Email Attachments to Media Library → PDF Parser → WP Tables

Shipping updates attached to WooCommerce orders

A fulfilment partner emails dispatch confirmations. The sender trigger catches only their mail, a Text Formatter extracts the order number and tracking code, and the note lands on the order.

Email from Specific Sender → Text Formatter → WooCommerce: Add Order Note

Agency lead alerts into the CRM

A client’s old website sends “New enquiry” emails that nobody wants to retype. The subject trigger picks them up, FluentCRM gets the contact, and the email is marked read so the inbox shows only what still needs a person.

Email with Subject Contains → FluentCRM: create contact → Mark Email as Read

One inbox, several aliases, routed by the original address

sales@, billing@ and partners@ all forward into one mailbox. A Router reads original_to and sends each message to the right team, even though they share an inbox.

Email Received → Router (original_to) → Slack · Email · Telegram

VIP customers never missed

A SaaS account manager wants to know the moment Priya Sharma at Acme writes in. The sender trigger flags the message so it stands out in every mail client, and a Telegram message follows.

Email from Specific Sender → Flag Email (Mark as Important) → Telegram

Tips and gotchas

A few things to know before you rely on IMAP email automation for a busy inbox:

  • Only unread mail is checked. If a person or a mail rule marks a message as read before the next check, it won’t start a run. The look-back covers roughly the last day.
  • Capture before you switch on. The captured email is the starting point; later checks process only mail newer than it.
  • Attachments in the trigger are a list, not files. The trigger gives each file’s name, size and type. To get the files, add Import Email Attachments to Media Library with the uid.
  • Move last. Every action finds the email by its UID in the folder you name, so run Move Email to Folder after the other mailbox actions.
  • Sender and subject filters are partial matches. “acme.example” in Sender Email matches every address at that domain.
  • Credentials are stored in your site’s database, base64-encoded and not encrypted, like other FlowMattic credentials. Use an app password or a dedicated mailbox where you can.
  • Checks run from FlowMattic’s own job table at the Frequency you choose. On a site connected to FlowMattic Cloud, Cloud wakes the site when a check is due; without it, WordPress cron runs the checks.

Related features

  • Email Parser: no mailbox to connect; forward mail to a workflow’s own address.
  • PDF Parser: read imported invoice and order PDFs into fields.
  • Router: send each email down the path that fits its sender, subject or AI label.

To send, sequence and approve by email as well, see email automation.

FAQ

Does it work with Gmail and Outlook?

It works with any mailbox that offers IMAP access with a username and password. For Gmail, the account form asks you to use an App Password rather than your normal password.

Do I need the PHP IMAP extension?

No. The module connects through a pure PHP library, so hosts without the IMAP extension are fine. It does need PHP 8.1 or later.

How quickly does a new email start the workflow?

Within the Frequency you set, which can be as short as 1 minute or as long as 1 day. The default is every 10 minutes.

Can it process emails that are already in my inbox?

The trigger is built for new mail: it checks unread messages from about the last day and skips anything older than the email you captured. For a one-off backlog, forward the messages to an Email Parser address instead.

Can a workflow save email attachments to WordPress?

Yes. Import Email Attachments to Media Library saves every attachment of a message and returns each file’s media ID and URL, ready for the next step.

Put your busiest inbox to work. See FlowMattic pricing and connect your first mailbox today.

More from the blog