# How We Built an Email-to-Swipe-File Pipeline (And You Can Too)
I was scrolling my inbox on a Tuesday morning and saw a killer ad in a newsletter. Beautiful creative, great copy, interesting offer structure. My immediate thought: "I need to save this to my swipe file."
But I was on my phone. In the Gmail app. And SwipeBase was open on my laptop across the room.
So I did what any lazy person would do — I forwarded the email to myself and told myself I'd save it later. I did not save it later. That email is still sitting in my inbox somewhere, unsaved, doing nothing.
That's when I decided: forwarding an email should BE the capture method. Forward it to a special address, and it shows up in your swipe file automatically. No extra steps. No "I'll do it later."
I told Ari to build it.
The Architecture (Simpler Than You'd Think)
Here's what we needed:
- A mail server that accepts inbound email
- A script that parses the email and extracts the good stuff
- A database insert that makes it show up in SwipeBase
We already had a VPS running SwipeBase. Adding a mail server was just a Postfix installation away.
Step 1: Postfix Pipe Transport
Postfix is the mail server. But we didn't need a full email setup — no mailboxes, no IMAP, no webmail. We just needed Postfix to accept mail for our domain and pipe it directly into a Node.js script.
The key config is the pipe transport. When mail arrives for any address at our domain, Postfix doesn't store it — it streams the raw email bytes directly to stdin of our processing script. The recipient address gets passed as an argument so we know which user it's for.
That's it. No mail storage. No spam filtering complexity. Just: email comes in → script runs → done.
Step 2: The Processing Script
This is where Ari did the real work. The process_email.js script handles three scenarios:
Scenario 1: Email with media attachments. If you forward a newsletter with images, or send yourself screenshots, the script extracts every attachment, classifies it (image, video, audio, PDF), saves the file to the user's upload directory, and creates a swipe item with the proper metadata. Images automatically get set as the thumbnail so they show up visually in your dashboard.
Scenario 2: Single-URL email. This is the clever one. If you forward an email that's basically just a link — like sharing a Facebook ad URL or an Instagram reel — the script detects that, extracts the URL, and routes it through our full URL capture pipeline instead. It even auto-detects the content type from the URL pattern: Meta Ad Library links become "ad" type, YouTube and TikTok links become "video" type, and so on. Then it triggers async scraping to grab screenshots, metadata, and AI-generated tags.
Scenario 3: Plain text email. No attachments, no single URL — just text content. The script saves the full email body (plain text and HTML) as a swipe item. Great for saving interesting copy, subject lines, or full newsletter layouts.
Step 3: User Matching and Security
Every SwipeBase user gets a unique inbound email address. When mail arrives, we look up the recipient address in the database to figure out which user's swipe file to add to.
We also have a sender whitelist. By default, only emails from your registered email address get processed. This prevents random people from stuffing items into your swipe file. You can adjust your whitelist if you forward from multiple accounts.
If no matching user is found, the email gets silently discarded. No bounce, no error reply — just gone. We never want our mail server to become a vector for spam bounces.
The User Experience
Here's what it looks like in practice:
- You sign up for SwipeBase and get assigned an inbound address like
yourname@capture.swipebase.co - You see a killer ad in a newsletter → forward the email to your capture address
- 30 seconds later, it's in your swipe file with the images extracted, categorized, and ready to reference
Or the URL flow:
- You're on your phone and see a great Facebook ad
- Copy the link, paste it in a new email, send to your capture address
- SwipeBase scrapes the page, grabs screenshots, runs AI tagging, and it shows up fully enriched
No app switching. No browser extensions. No "save for later" that you never come back to. Email is the universal input method — every device, every app, every platform can send an email.
The Technical Details That Matter
A few things I want to call out because they tripped us up:
Never bounce. The script catches all errors and exits cleanly with code 0. If something goes wrong parsing an email, we log it and move on. A bouncing mail server is a nightmare — you'll get blacklisted, generate backscatter spam, and create support tickets. Swallow errors silently.
File type detection is harder than you think. MIME types from email clients are unreliable. We check both the Content-Type header AND the file extension, with extension taking priority in ambiguous cases. A file called photo.jpg with a content type of application/octet-stream should be treated as an image.
UUID everything. Every saved file gets a UUID filename. Never trust the original filename — it could contain path traversal characters, unicode weirdness, or collide with existing files. UUID + original extension is the move.
Strip email signatures from URL detection. When checking if an email is "just a URL," you need to strip out signatures like "Sent from my iPhone," quoted reply text, forwarded message headers, and Outlook cruft. Otherwise a simple forwarded link with an auto-signature gets misclassified as a multi-content email.
What I'd Do Differently
If I were building this from scratch today, I'd add:
Confirmation replies. A quick "✅ Saved: [title]" reply email so you know it worked. Right now it's fire-and-forget, which means you don't know if it actually captured until you check your dashboard.
Duplicate detection. If you forward the same newsletter twice, you get two swipe items. Should probably hash the content and dedupe.
Newsletter auto-subscribe. If I'm forwarding emails from the same sender repeatedly, SwipeBase should just ask if I want to auto-capture everything from that sender going forward.
Build It Yourself
If you're running your own VPS, this whole setup takes about an hour:
- Install Postfix (your distro's package manager)
- Configure the pipe transport to point at your processing script
- Set up DNS records (MX + SPF) for your capture domain
- Write a script that reads stdin, parses with a mail parsing library, and does whatever you want with the content
The barrier to entry is having a server with port 25 open, which most cloud providers block by default. You'll need to request SMTP access or use a provider that allows it.
Or just use SwipeBase and skip the infrastructure headaches. Every account gets email capture built in.
The Bigger Picture
This email pipeline is one piece of a larger philosophy: capture should be frictionless. The moment you add steps between "I found something interesting" and "it's saved in my system," you lose items. Every extra tap, every context switch, every "I'll do it later" is a leak in your creative pipeline.
We've built capture via browser extension, iOS shortcut, URL paste, and now email forwarding. The goal is: no matter where you are or what device you're using, saving to your swipe file is one action away.
Because the best swipe file is the one you actually use.
---
Building SwipeBase in public. Follow the journey at machineearned.com or grab the newsletter below.