>> Delete No. 918 article
No. 쉘 상에서 간단히 첨부파일 보내기...

등록 2001-01-03 18:13:00     조회 5
이름 지나간다    

		쉘 상에서 별다른 메일 클라이언트를 쓰지 않고 간단히 첨부파일을
포함한 메일을 보내는 스크립트를 만들었습니다. 너무 허접하자만
전 잘 쓰고 있어요. :)
  사용법은...
 [root@www /root]# amail zoo11 at aw23.com tel
Subject: test for att. file
From (Enter for root at www.xxcas.com): damn at damn.com Write your messages here. End with CTRL-D
test.
ok?
Sending...Done.
[root@www /root]#
  #!/bin/sh
 trap 'rm -f /tmp/amail*.tmp 1> /dev/null 2>&1 ; exit 1' 0 1 2 15
MAILTO=$1
ATTFILE=$2
HOST=`hostname -f`
MIME=`type -path mimencode` 2> /dev/null
ME=`basename $0`
SMAIL=`type -path sendmail` 2> /dev/null
 if [ -z $SMAIL ] ; then
echo "sendmail does not exist in your PATH! Quit..." ; exit 1
fi
 if [ -z $MIME ] ; then
echo "mimencode does not exist in your PATH! Quit..." ; exit 1
fi
 if [ $# -ne 2 ] ; then
echo "Usage:$ME <mailto> <attfile>" ; exit 1
fi
 if [ ! -f $ATTFILE ] ; then
echo "A file $ATTFILE does not exist or not a regular file. Quit..." ; exit 1
fi
 echo -n "Subject:"
read SUBJ
echo -n "From (Enter for $USER@$HOST): "
read FROM
if [ -z $FROM ] ; then
FROM=$USER@$HOST
fi
 echo "Write your messages here. End with CTRL-D"
cat > /tmp/amail.tmp 2> /dev/null
 $MIME $ATTFILE > /tmp/amailat.tmp 2> /dev/null
 cat > /tmp/amailfi.tmp << _EOF
MIME-Version:1.0
Content-Type: multipart/mixed; boundary="zYM0uCDKw75$$"
Content-Disposition: inline
From:$FROM
Subject:$SUBJ
 --zYM0uCDKw75$$
Content-Type: text/plain
Content-Disposition: inline
 `cat /tmp/amail.tmp`
 --zYM0uCDKw75$$
Content-Type: application/octet-stream; name="`basename $ATTFILE`"
Content-Transfer-Encoding: base64
 `cat /tmp/amailat.tmp`
 _EOF
 echo -n "Sending..."
$SMAIL $MAILTO < /tmp/amailfi.tmp && echo "Done."--God save the queen.
[관리자] 패스워드를 입력 하십시오. 답장이 존재하면 함께 삭제됩니다.[ 목록 | 이전 ]
패스워드:    

Copyleft 1999-2026 by JSBoard Open Project
Theme Designed by IDOO All right reserved