2011-03-22 9 views

cevap

0

sendmail'un bu konuda size yardımcı olamayacağını düşünüyorum. mutt gibi bir müşteriye gidin ve ör. mutt -a file1 -a file2 -- [email protected]. Ya da perl'a gidin.

+0

Tüm sistemler iti yüklemek yeteneğine sahip olacak, bu yüzden soru sorulduğunda olarak :) – stevepastelan

+0

Sendmail'de @stevepastelan sadece yapamaz tavsiyeniz sendmail veya mailx kullanması gerekir birine çok yararlı değildir ek araçlar olmadan. Seçtiğiniz araçlar elbette size kalmış. – ShiDoiSi

+1

Ama elbette, sendmail * yapabilir *. Bu sadece içeriğin nasıl gönderileceğini biçimlendirmek için bir soru. – stevepastelan

9

böyle birden ekleri ile e-posta gönderebilirsiniz sisteminizde mevcut uunecode var varsayarsak:

İşte
#!/bin/bash 

... 
... 
... 
BOUNDARY="=== This is the boundary between parts of the message. ===" 

{ 
    echo "From: $MAILFROM" 
    echo "To: $MAILTO" 
    echo "Subject:" $SUBJECT 
    echo "MIME-Version: 1.0" 
    echo "Content-Type: MULTIPART/MIXED; " 
    echo " BOUNDARY="\"$BOUNDARY\" 
    echo 
    echo "  This message is in MIME format. But if you can see this," 
    echo "  you aren't using a MIME aware mail program. You shouldn't " 
    echo "  have too many problems because this message is entirely in" 
    echo "  ASCII and is designed to be somewhat readable with old " 
    echo "  mail software." 
    echo 
    echo "--${BOUNDARY}" 
    echo "Content-Type: TEXT/PLAIN; charset=US-ASCII" 
    echo 
    echo "This email comes with multiple attachments." 
    echo 
    echo 
    echo "--${BOUNDARY}" 
    echo "Content-Type: application/zip; charset=US-ASCII; name="${ZIPFILE} 
    echo "Content-Disposition: attachment; filename="`basename ${ZIPFILE}` 
    echo 
    uuencode $ZIPFILE $ZIPFILE 
    echo 
    echo "--${BOUNDARY}--" 
    echo "Content-Type: application/pdf; charset=US-ASCII; name="${PDFFILE} 
    echo "Content-Disposition: attachment; filename="`basename ${PDFFILE}` 
    echo 
    uuencode $PDFFILE $PDFFILE 
    echo 
    echo "--${BOUNDARY}--" 
} | /usr/lib/sendmail -t 
+0

Yukarıda önerilen yöntemden gönderilen posta ekte dosyayı gönderebilir, ancak görünüm pencereleri posta istemcisinde kodlanmış bir dosya olarak alınır. Dosyayı, alıcının sonu olarak şifresi çözülmüş bir dosya olarak alınacak şekilde nasıl gönderilir? – greperror

0

Ben insanlara üretmek raporlar göndermek için kullandığı bir bash script. Ek olarak gönderilirler. HTML’nizi komut dosyasının "gövde" değişkenine yerleştirin. Değişkenlerin parametrelerini size bırakırım.

#!/bin/bash 

function get_mimetype(){ 
file --mime-type "$1" | sed 's/.*: //' 
} 

from="[email protected]" 
to="[email protected]" 
subject="Your Report my Lord" 
boundary="=== Boundary ===" 
body="The reports are attached to this email" 
declare -a attachments 
attachments=("fileOne.out" "fileTwo.out" "fileThree.out" "file-et-cetera.out") 

# Build headers 
{ 

printf '%s\n' "From: $from 
To: $to 
Subject: $subject 
Mime-Version: 1.0 
Content-Type: multipart/mixed; boundary=\"$boundary\" 

--${boundary} 
Content-Type: text/plain; charset=\"US-ASCII\" 
Content-Transfer-Encoding: 7bit 
Content-Disposition: inline 

$body 
" 

for file in "${attachments[@]}"; do 

     [ ! -f "$file" ] && echo "Attachment $file not found, omitting file" >&2 && continue 

     mimetype=$(get_mimetype "$file") 

    printf '%s\n' "--${boundary} 
Content-Type: $mimetype 
Content-Transfer-Encoding: base64 
Content-Disposition: attachment; filename=\"$file\" 
    " 

    base64 "$file" 
    echo 
done 

# print last boundary with closing -- 
printf '%s\n' "--${boundary}--" 

} | sendmail -t -oi 
İlgili konular