如何使用sendmail发送带有多个文本附件的HTML正文电子邮件

vai*_*war 8 unix sendmail

我想将HTML文件作为邮件正文发送,并希望将多个文本文件附加到此电子邮件中.

由于需要发送html文件,因此必须使用sendmail(我无法使用mailx).

如何使用sendmail发送HTML正文电子邮件和多个文本附件?

anu*_*ava 9

假设您的系统中有可用的uunecode,您可以发送包含多个附件的电子邮件,如下所示:

#!/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
Run Code Online (Sandbox Code Playgroud)


Shi*_*iSi 0

我认为sendmail这不会帮助你。去找像这样的客户mutt,然后做例如mutt -a file1 -a file2 -- recipient@do.main。或者去perl