>> Delete Reply from No. 32949 article
No. RE: cron에서 메일발송(파일첨부)

등록 2001-06-13 11:02:00 By localhost     조회 2
이름 차주현    

		: cron데몬에서 메일을 발송해야 하는데..
: 파일을 첨부해서 보내야 합니다.
:
: 방법을 알려주세여..
 제가 개인적으로 쓰려고 만든 스크립트를 보여드리죠.
수정해서 쓰시던지 하세요. 이 스크립트는 sendmail 과 mimencode 가 필요
합니다.
사용법도 함께 적습니다.
크론으로 돌릴때는 두번째 here document 를 쓰는게 좋겠죠.
  [zoo11@www zoo11]$ more `which amail`
#!/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."
[zoo11@www zoo11]$
[zoo11@www zoo11]$ amail zoo11 at 3dbot.com proto.jpg
Subject: hi. it's test mail for file attachment.
From (Enter for zoo11 at www.jexit.com):
Write your messages here. End with CTRL-D
test mail.
it include a attached file proto.jpg
Sending...Done.
[zoo11@www zoo11]$ amail zoo11 at 3dbot.com proto.jpg << _EOF_
> Here's subject.
> mailfrom at mail.com > here's contents.
> write down a message. end with _EOF_
>
> _EOF_
Subject: From (Enter for zoo11 at www.jexit.com): Write your messages here. End wit
h CTRL-D
Sending...Done.
[zoo11@www zoo11]$--껌을 씹을 때는 조용히...
[관리자] 패스워드를 입력 하십시오. 답장이 존재하면 함께 삭제됩니다.[ 목록 | 이전 ]
패스워드:    

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