← All articles
Agent Identities5 min read

Make Attachments a Separate Decision in Agent Email

MR
Brian Brackeen
Mailrun notes · Nov 2026

A customer sends an email with a PDF attached. Your agent can answer questions from the message body, so passing the PDF into the same workflow seems like a small extension. It is a different decision. The file needs a handling path, and anything extracted from it is still material supplied by someone outside your business.

Before enabling attachment processing, decide what useful work the agent should do with one specific kind of file. Extracting a reference number from an expected document is a narrower task than accepting every attachment and deciding what to do next.

The following is a proposed operating approach for the application connected to your agent mailbox. It does not describe automatic Mailrun features or guarantee that a particular file is safe.

Start With the Business Task

Write down the smallest useful attachment workflow. For a hypothetical service inquiry, that might be: read an approved document format, extract the customer's requested service and reference number, and prepare a summary for a colleague. The attachment does not authorize a booking, a payment or a change to the customer's account.

Name the person responsible for exceptions. If the file cannot be processed, the agent needs somewhere to send the question without forwarding suspicious content to a colleague's ordinary inbox by default.

Keep the first version deliberately narrow:

These are design choices to settle before accepting live documents, not questions for the model to improvise after a file arrives.

Check the File Before Giving Its Contents to the Agent

A familiar filename is not enough to establish the file's type or safety. OWASP's File Upload Cheat Sheet recommends layered controls, including allowed file types, size limits, file validation and appropriate scanning. It warns against trusting the supplied Content-Type alone.

Apply those principles to the attachment-processing service, with controls suited to its actual file formats and tools. Have the application owner document where the file is stored and which isolated processing component is allowed to open it. Keep that component maintained and restrict its access to systems unrelated to the extraction task.

Do not have the email agent launch arbitrary programs, enable document macros or install a missing viewer because an attachment asks it to. If the normal processing path cannot handle the file, use the exception path. A scanner result is one input to that decision, not permission to give the document control over the workflow.

Separate Reading From Authority

A successfully extracted paragraph can still contain instructions aimed at the agent. A document might say to ignore earlier rules, forward other correspondence or send its summary to an address printed inside the file.

OWASP's prompt-injection guidance identifies external files as a possible source of indirect prompt injection. It recommends limiting privileges and using human approval for high-risk operations. Neither a clean scan nor a well-written system prompt establishes that extracted text is trustworthy.

For the hypothetical inquiry, the document can supply a requested service and reference number. It cannot change the approved recipient, expand the agent's tool access or override the handling rules. Enforce those boundaries in the application's permissions and action checks, rather than relying only on a sentence telling the model to behave.

Keep the original request and the extracted evidence distinguishable in the review view. A colleague should be able to tell which statement came from the sender, which came from the document and which is the agent's interpretation. That makes a mistaken extraction easier to challenge before someone acts on it.

Give Exceptions an Honest Response

An unreadable attachment should not produce a confident summary. Decide what the sender will hear when processing is incomplete, and make the wording match what actually happened.

For example, if the workflow received a message but could not read its file, a reply can explain that the attachment could not be processed and ask for the needed information through an approved alternative. Do not say a specialist has reviewed it unless that review occurred. Do not ask the sender to remove encryption or send sensitive documents to a less protected channel merely to make the automation easier.

Human review also needs a safe route. Give the responsible person access through the business's approved handling process, with the failure reason and enough context to decide the next step. The exception queue should not become an unmonitored collection of original files and unresolved requests.

Rehearse Failures, Not Just the Clean Example

Use synthetic, non-sensitive documents in a controlled test. Include a normal supported file, an unsupported type, an oversized file, an encrypted file and a document containing a harmless instruction that conflicts with the task. Do not use live malware for an ordinary workflow rehearsal.

For each case, record what the application received, whether extraction ran, what the agent proposed and whether any outgoing action occurred. Check the actual action records, not only the model's statement that it followed the rules. Confirm that the exception reaches its assigned owner and that unauthorized destinations are rejected by the application.

A useful first release is one attachment task with known limits and a working exception path. Add formats or actions only after deciding what new access they require and repeating the relevant checks. The mailbox can receive more than the agent is allowed to process. Keeping that distinction explicit is part of making an email agent useful without giving every incoming file a vote in how the business runs.

Talk through your Mailrun setup.

Ask about Agent Identities for your agent or ours, or Mailrun Core for your sequencer. Our team can help you choose.

Book a call