#!/bin/sh
DIR='./'
FILE='abababa.txt'
NKF='/usr/bin/nkf'
SENDMAIL='/usr/sbin/sendmail'
TO='[email protected]'
FROM='[email protected]'
BOUND=`date +"%Y%m%d%H%M%S"`
Err(){ echo "$1">&2; exit 1; }
Check_file(){ test -f $1 || return 1; return 0; }
Msg()
{
echo "To:${TO}
Subject: サブジェクト
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary=\"---------${BOUND}\"
-----------${BOUND}
Content-Type: Text/Plain; charset=ISO-2022-JP
Content-Transfer-Encoding: 7bit
本文
-----------${BOUND}
Content-Type: application/octet-stream;
name=\"${FILE}\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename=\"${FILE}\"
" | ${NKF} -j -m0
cat ${DIR}/${FILE} | ${NKF} -sMB
echo ""
echo "-----------${BOUND}--"
}
## main
Check_file ${DIR}/${FILE} || Err "Warning : Cannot open ${FILE}"
Msg | ${SENDMAIL} -f${FROM} ${TO}
exit 0
参考・引用: http://d.hatena.ne.jp/pipi_one/20100513/1273756227
最終更新: 2019年1月17日 (木) 04:12