Skip to content

Instantly share code, notes, and snippets.

@StevenMaude
Last active August 13, 2024 22:38
Show Gist options
  • Save StevenMaude/914e9187c09027866fe88958798acb7e to your computer and use it in GitHub Desktop.
Save StevenMaude/914e9187c09027866fe88958798acb7e to your computer and use it in GitHub Desktop.
DEPRECATED: see https://github.com/StevenMaude/go-mailin8 — Retrieve most recent email from a mailinator.com temporary email box using curl and jq at the command line; useful if you just want some account activation link, but too lazy to visit the site directly. (It's actually mailinfewerthan8usefullines, rather than mailin8usefullines, but, hey…
#!/bin/bash -e
# mailin8.sh: Collect From, Subject, Body from most recent mail
# in a mailinator.com account.
# Usage: mailin8.sh <local_mailbox_name>
# <local_mailbox_name> is the bit before @mailinator.com
# Create temporary file for cookiejar
TEMP=$(mktemp)
trap 'rm $TEMP' EXIT
INBOX=$1
MAIL_ID=$(curl -s "https://www.mailinator.com/api/webinbox2?x=0&public_to=$INBOX" | jq --raw-output '(.public_msgs | .[length-1]).id')
# The first request below doesn't give us anything useful, but the second
# request fails if we don't save the cookie from here first.
curl -s -c "$TEMP" "https://www.mailinator.com/inbox2.jsp?public_to=$INBOX" > /dev/null
curl -s -b "$TEMP" "https://www.mailinator.com/fetchmail?msgid=$MAIL_ID&zone=public" | jq --raw-output '.data.headers.from, .data.headers.subject, .data.parts[0].body'
@StevenMaude
Copy link
Author

Made a Go version that runs standalone, no jq required.

@StevenMaude
Copy link
Author

StevenMaude commented Mar 26, 2018

Mailinator doesn't work like this anymore, but updated the Go code to work with another service, see the repo linked above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment