#! /bin/bash

# 2008/07/29  Anonymous remailer
# Copyright Andrew McGill, distributable under terms of GPL version 3

ADDRESS="$1"
DATE=`date -R`
BOUNDARY="Boundary_00=2218295.rk6o5hM.$$.$RANDOM.$RANDOM"
NEXTPART="nextPart2218295.rk6o5hM.$$.$RANDOM.$RANDOM"
cat <<EOF
From: remail <$ADDRESS>
To: <$ADDRESS>
Subject: No subject
X-Loop: $ADDRESS
Date: $DATE
User-Agent: Anon remail
MIME-Version: 1.0
Content-Type: Multipart/Mixed;
  boundary="$BOUNDARY"
Content-Transfer-Encoding: 7bit

--$BOUNDARY
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Attached


--$BOUNDARY
Content-Type: multipart/encrypted;
  boundary="$NEXTPART";
  protocol="application/pgp-encrypted"
Content-Transfer-Encoding: 7bit


--$NEXTPART
Content-Type: application/pgp-encrypted
Content-Disposition: attachment

Version: 1
--$NEXTPART
Content-Type: application/octet-stream
Content-Disposition: inline; filename="msg.asc"

EOF

{
cat <<EOF
Content-Type: message/rfc822;
  name="forwarded message"
Content-Transfer-Encoding: 7bit
Content-Description: Encoded for <$ADDRESS>: Re: something
Content-Disposition: inline

EOF
cat
} | gpg --batch --yes -a --encrypt --recipient $ADDRESS

cat << EOF

--$NEXTPART--

--$BOUNDARY--
EOF

# And we're done!

