2014-01-20 3 views
1

uuencodesendmail과 함께 여러 개의 첨부 파일을 보낼 수 있습니까?명령 줄과 센드 메일을 사용하여 여러 첨부 파일이있는 전자 메일 보내기

$attachments=attachment_1.pdf attachment_2.pdf attachment_3.pdf attachment_4.pdf 
또한

A는 $template 변수처럼 :

$template="Subject: This is the subject 
From: [email protected] 
To: %s 
Content-Type: text/plain 

This is the body. 
" 

내가 온 스크립트에서

내가 좋아하는 하나의 전자 메일에 첨부해야하는 파일이 포함 된 변수가 최대 :

printf "$template" "$recipient" | 
sendmail -oi -t 

어딘가에 나는에 모든 것을 첨부해야합니다.변수가 있습니까?

+0

[mailx] (http://en.wikipedia.org/wiki/Mailx) 옵션이 있습니까? 그렇다면'-a' 스위치를 사용하여 여러 개의 전자 메일을 보낼 수 있습니다. 바닐라 센드 메일을 사용해야합니까? –

+0

http://stackoverflow.com/questions/19940292/using-uuencode-to-attach-multiple-attachments-from-a-variable-to-an-e-mail-and-s에서 답을 확인하십시오. uuencode를 통해 첨부 파일을 포함하는 변수를 구문 분석하는 방법. – Incognito

답변

4
attachments="attachment_1.pdf attachment_2.pdf attachment_3.pdf attachment_4.pdf" 
recipient='[email protected]' 

#() sub sub-shell should generate email headers and body for sendmail to send 
(
# generate email headers and begin of the body asspecified by HERE document 
cat - <<END 
Subject: This is the subject 
From: [email protected] 
To: $recipient 
Content-Type: text/plain 

This is the body. 

END 
# generate/append uuencoded attachments 
for attachment in $attachments ; do 
    uuencode $attachment $attachment 
done 
) | /usr/sbin/sendmail -i -- $recipient