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

등록 2001-06-13 11:02:00     조회 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]$--껌을 씹을 때는 조용히...
이름
암호


>> 관련글
32949 cron에서 메일발송(파일첨부)  김은성  2001.06.13  ....
  답장 RE: cron에서 메일발송(파일첨부)  차주현  2001.06.13  ....
Register [ localhost 목록보기 윗글 아랫글
글쓰기
답장쓰기 수정 삭제
정규표현식 [ 상세 검색 ]
페이지로딩: [ 0.81 초 ] 작업시간: [ 0.5 초 ]

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

적수네 동네
+
| 적수네 동네
| 공부방
| 리눅스 잡지 서고
| LSN 소스
| 링크 모음
+---+
게시판
+
| 떠들어보세!
| 질문과 답변
| 새소식과 정보
| 1원짜리 팁?
| 대화방
+---+
칼럼?
+
| 세하 훔쳐보기
| Welcome2nite
| 혜진의 염장판
+---+
리눅스 상표권
+
| 반대 서명란
| 토론 게시판
+---+
GNU
+
| GNU 선언문
| GNU GPL
| GNU 미러 목록
+---+
프로젝트?
+
| 리눅스카운터
| RC5DES
| 실질헌법 제작
+---+
커널 소식
+
| 안정 버젼: 2.4.14
+---+
테마 선택
+
LSN 방송국?
+
| OFF AIR
+---+
회원
+
| 로그인
+---+
[ 적수네 동네 ] [ 리눅스 상표권 독점 반대 ] [ 한글 리눅스 문서 프로젝트 ] [ KrLine ] [ 사랑넷 ] [ Valid HTML 4.0! ] [ SlashDot ] [ Freshmeat ]
Copyleft (C) 1998-2001 Byeong-Chan Kim . License
TIME: 1789523556
System by WYZsoft, HDD by I.O.Linux, Mizi Research, Embryo, WOWLINUX, Domain by SarangNet, Network by KrLine.