0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

添付ファイルをコマンドラインで送信

Last updated at Posted at 2015-05-12

参考

コマンド

uuencode ファイル ファイル名 | mail -s "件名" hoge@hoge.com
画像送信例
uuencode /srv/motion/a.jpg a.jpg | mail -s "件名" hoge@hoge.com

kindleに送る例

sendtokindle.sh
# !/bin/sh
set -eu
SEND_TO_KINDLE_EMAIL="xxxxxxxx@kindle.com"

is_allowed_ext(){
  EXTENSION=$1
  case $EXTENSION in
    "doc" | "docx" | "rtf") echo 0;;
    "htm" | "html" | "txt") echo 0;;
    "zip") echo 0;;
    "jpg" | "bmp" | "png") echo 0;;
    "pdf") echo 0;;
    *) echo 1;
  esac
}

if [ ! $# -eq 1 ];then
    echo "ファイルを指定してください。"
    exit 1
fi
FILE=$1
if [ ! -e $FILE ];then
    echo "$FILEは存在しません。"
    exit 1
fi
BASENAME=`basename $FILE`
EXTENSION=${BASENAME##*.}
CHECKED_RESULT=`is_allowed_ext $EXTENSION`

if [ ! $CHECKED_RESULT -eq 0 ];then
    echo "その拡張子のファイルは送信できません。"
    exit 1
fi

uuencode $FILE $BASENAME | mail -s "sendtokindle" $SEND_TO_KINDLE_EMAIL
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?