我试图在unix中使用sendmail函数,但似乎无法获得附件,through...my代码就是其中之一:
export MAILTO="me@myco.com"
export SUBJECT="test mail"
export ATTACH="/home/tstattach"
(
echo "To: $MAILTO"
echo "Subject: $SUBJECT"
echo "MIME-Version: 1.0"
echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
echo "this is a test message"
base64 $ATTACH
) | sendmail $MAILTO我的电子邮件是这样通过的,没有附件:
this is a test message
dGVzdCBhdHRhY2htZW50
---q1w2e3r4t5--我怎样才能让依恋通过?它似乎以一种奇怪的方式对它进行编码.我也尝试过uuencode而不是base64,但是后来我发现了一个错误,说uuencode找不到.
发布于 2015-01-03 14:59:36
好吧,今天感觉不错。下面是一个工作(测试):
export MAILTO="me@myco.com"
export SUBJECT="test mail"
export ATTACH="/home/tstattach"
(
echo "Date: $(date -R)"
echo "To: $MAILTO"
echo "Subject: $SUBJECT"
echo "MIME-Version: 1.0"
echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
echo
echo '---q1w2e3r4t5'
echo 'Content-Type: text/plain; charset=utf-8'
echo 'Content-Transfer-Encoding: 8bit'
echo
echo "this is a test message"
echo '---q1w2e3r4t5'
echo 'Content-Type: text/plain; charset=utf-8; name=attach.txt'
echo 'Content-Transfer-Encoding: base64'
echo 'Content-Disposition: attachment; filename=attach.txt'
echo
base64 <"$ATTACH"
echo
echo '---q1w2e3r4t5--'
) | sendmail $MAILTO但是请做,帮自己一个忙,阅读eMail (RFC822及其替代品)和MIME (RFCs在2047年左右)。
https://stackoverflow.com/questions/27708212
复制相似问题