首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >发送附件正在编码的邮件

发送附件正在编码的邮件
EN

Stack Overflow用户
提问于 2014-12-30 15:34:12
回答 1查看 4.2K关注 0票数 1

我试图在unix中使用sendmail函数,但似乎无法获得附件,through...my代码就是其中之一:

代码语言:javascript
复制
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

我的电子邮件是这样通过的,没有附件:

代码语言:javascript
复制
this is a test message
dGVzdCBhdHRhY2htZW50
---q1w2e3r4t5--

我怎样才能让依恋通过?它似乎以一种奇怪的方式对它进行编码.我也尝试过uuencode而不是base64,但是后来我发现了一个错误,说uuencode找不到.

EN

回答 1

Stack Overflow用户

发布于 2015-01-03 14:59:36

好吧,今天感觉不错。下面是一个工作(测试):

代码语言:javascript
复制
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年左右)。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27708212

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档