Slip Ahead Logging

It's not your fault at all.

Kindle に sendmail で届け

uuencode では受け付けてくれなかったので base64 エンコーディングを行なう.

#!/bin/sh

if [ $# -eq 0 ]; then
    echo "Usage: $0 FILE"
    exit
fi

FILE=$1

FROM="あなたのメールアドレス"
TO="あなたの @free.kindle.com なアカウント名"
SUBJECT=""

MIME=$(file --mime $FILE | cut -d ' ' -f 2)
ENCODING=base64
boundary="---my-unlikely-text-for-mime-boundary---$$--"

(cat <<EOF
From: $FROM
To: $TO
Subject: $SUBJECT
Date: $(date +"%a, %b %e %Y %T %z")
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="$boundary"
Content-Disposition: inline

--$boundary
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

This email has attached the file

--$boundary
Content-Type: $MIME;name="$FILE"
Content-Disposition: attachment;filename="$FILE"
Content-Transfer-Encoding: $ENCODING

EOF
    base64 $FILE
    echo ""
    echo "--$boundary") | sendmail -t