How to Auto-Forward Emailed Attachments with a Branded Cover Email

Point a document straight at a Spojit Mailhook address, fetch the file bytes with an Attachment node, and re-send the same file to a distribution list wrapped in a templated cover message from a Send Email node.

What This Integration Does

Teams often receive a single document by email (a signed contract, a price list, a daily report) that then has to be forwarded to a wider group, every time, by hand. This workflow removes that manual step in Spojit: a supplier or system emails the file once, and Spojit automatically relays it to everyone who needs it, with a consistent cover note so the recipients always know what the attachment is and where it came from. Because the cover message is templated, every forward looks the same and carries the original sender, subject, and a short summary line.

The run model is push-based. A Mailhook trigger gives you a dedicated address; any mail that lands on it starts a run within seconds, with no mailbox or login to manage. The trigger exposes the message and a list of attachment references as {{ input }}. An Attachment node then pulls the real bytes of the matching file, and a Send Email node sends that file onward through Spojit's built-in mail service. Each inbound email is deduplicated, so a message is processed once even if it is retried. The workflow leaves no stored state of its own: it reads the inbound mail, forwards the file, and finishes. Re-runs are independent, so re-sending the same source email simply produces another forward.

Prerequisites

  • A workflow in the Spojit designer with a Trigger node set to type Mailhook.
  • The list of recipients you want the file forwarded to. External addresses must be added to your organization allowlist under Settings -> General -> Email recipients before a Send Email node can reach them.
  • A clear rule for which attachment to forward (for example, only PDFs, or only a file named like invoice-*.pdf) so the Attachment node selects the right file.
  • Awareness of the default limits: up to 10 MB per attachment and 25 MB per run, and inbound emails are retained for 30 days.

Step 1: Generate the Mailhook address

Add a Trigger node and set Trigger Type to Mailhook. Optionally set an Address prefix (1 to 24 characters, default mh) so the address is recognizable, for example contracts. Click Generate email address to mint a unique address of the form contracts-<random16>@mailhook.spojit.com, then copy it. Point your source of documents at this address: a supplier's "send a copy to" field, an internal forwarding rule, or a system notification setting. The Mailhook fires whether the address is in To, Cc, or Bcc, and it never replies to the sender, so any acknowledgement you want must come from a Send Email node later in the flow.

Step 2: Filter to the right inbound emails (optional but recommended)

On the same Mailhook trigger, set the optional From allowlist to the addresses you expect documents from, and a Subject regex to match only the messages you want to forward. For example, a From allowlist of docs@yoursupplier.com and a Subject regex such as ^Price List ensures the workflow ignores unrelated mail that happens to reach the address. Filtering here keeps the run count down and stops stray messages from triggering a forward. After the run, the trigger output is available as {{ input }}, including {{ input.from }}, {{ input.subject }}, {{ input.replyTo }}, and the attachment references in {{ input.attachments }}.

Step 3: Fetch the attachment bytes

Add an Attachment node directly after the trigger. This node only works in Mailhook workflows; it reads the references the trigger produced and returns the actual file content. Set Mode to Single to grab the first matching file as one object. Narrow the match with a Content type filter such as application/pdf and a Filename pattern glob such as *.pdf. If you need a specific file regardless of other filters, set Attachment ID to its exact id. Turn on Fail if no attachment matches so the run stops clearly when an expected file is missing rather than silently forwarding an empty email. With Single mode the node outputs:

{
  "filename": "price-list-2026.pdf",
  "contentType": "application/pdf",
  "size": 184320,
  "content": "<base64-encoded bytes>"
}

The content field is base64 and feeds straight into the next step. Give the node an output variable, for example attachment, so you can reference {{ attachment.content }} and {{ attachment.filename }}.

Step 4: Build the templated cover message

Add a Send Email node. This sends from Spojit's built-in mail service, so no connection is required. In Recipients, enter your distribution list as a comma-separated string, for example team@yourcompany.com, ops@yourcompany.com. In Subject, template the original subject so context carries through, for example Forwarded: {{ input.subject }}. In Body (plain text), write a consistent cover note that names the original sender and the file:

Hi team,

A new document has arrived and is attached for your reference.

From:    {{ input.from }}
Subject: {{ input.subject }}
File:    {{ attachment.filename }}

This was forwarded automatically by Spojit.

Set Reply-To to {{ input.replyTo }} so that anyone replying to the forward reaches the original sender rather than the workflow owner. Only upstream variables resolve in these fields, which is exactly what you have here from the trigger and the Attachment node.

Step 5: Attach the original file to the outgoing email

In the same Send Email node, add an attachment and supply the base64 content and filename from Step 3: pass {{ attachment.content }} as the attachment bytes and {{ attachment.filename }} as the name. This re-sends the exact same file the Mailhook received. Keep an eye on the size limits: a single attachment over 10 MB or a run over 25 MB will not be fetched by default, so very large documents need to be handled differently (see Tips). Set If sending fails to Fail the workflow while you are getting this working so that a delivery problem is visible in the execution history rather than hidden.

Step 6: Handle multiple attachments (optional)

If a single email can carry several files you want to forward, set the Attachment node Mode to Multiple instead. The node then outputs a list:

{
  "attachments": [ { "filename": "...", "contentType": "...", "size": 0, "content": "..." } ],
  "count": 2,
  "totalBytes": 263168
}

Add a Loop node in ForEach mode over {{ attachment.attachments }} and place a Send Email node inside the loop body, referencing {{ item.content }} and {{ item.filename }} for each file. Alternatively, send one email and attach each file from the list. Choose Single mode when you always forward exactly one document, and Multiple mode when the count varies.

Tips

  • Use the From allowlist and Subject regex filters on the trigger to avoid forwarding spam or auto-replies that reach the Mailhook address.
  • For files larger than the 10 MB per-attachment limit, forward a link instead of the bytes: store the document elsewhere with a connector such as FTP (upload-file) and put the resulting location in the cover email body.
  • Reference the original sender with {{ input.replyTo }} in the Send Email Reply-To field so replies route back to the source, not to the workflow owner.
  • To send the forward from your own domain rather than Spojit's mail service, swap the Send Email node for the Resend connector (send-email) or the SMTP connector (send-email).

Common Pitfalls

  • Adding an Attachment node without a Mailhook trigger: the designer refuses to save it. The Attachment node only works in Mailhook workflows.
  • Forgetting the recipient allowlist: external addresses in the Send Email Recipients field must be on the org allowlist under Settings -> General -> Email recipients, or the send is blocked.
  • Leaving Fail if no attachment matches off: an email with no matching file then sends a cover email with nothing attached. Turn it on so the run fails clearly instead.
  • Expecting an automatic reply to the sender: a Mailhook never responds to the originating email. If the sender needs an acknowledgement, add a separate Send Email node addressed to {{ input.replyTo }}.

Testing

Validate on a small scope before announcing the address. Temporarily set the Send Email Recipients to just your own address, then email a known PDF to the Mailhook address from an allowlisted sender. Open the run in execution history and confirm the Attachment node returned the expected filename, contentType, and a non-zero size, and that the cover email arrived with the file attached and the templated From, Subject, and File lines filled in. Try an email with no matching attachment to confirm the workflow fails as expected when Fail if no attachment matches is on. Once the single-recipient test passes, switch the Recipients field to your full distribution list. If anything looks off, ask Miraxa, the intelligent layer across your automation, "Why did my last run fail?" to investigate the execution.

Learn More

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.