0

我正在尝试使用附件将其添加x-header X-APP-VOLT: Yes到我的电子邮件标题中.tar。我只能访问usr/sbin/sendmailmailx。我没有 root 访问权限,所以我无法下载其他版本的mailxor mutt

我可以使用下面的代码添加x-headerusr/sbin/sendmail但我不知道如何添加.tar附件。

/usr/sbin/sendmail -i -- toemail << END
To: toemail
Subject: Test
X-APP-VOLT: Yes

Hope this works! END

我可以使用以下代码附加.tar文件mailx,但我不知道如何添加x-header. 我的mailx也没有-a选项。

cat file | uuencode filename | mailx -s "Test" toemail

谢谢

4

1 回答 1

0

一种方法是在临时文件中构造您的输入:

cat > tmpfile$$ << END
To: toemail
Subject: Test
X-APP-VOLT: Yes

Hope this works!

END

uuencode filename < file >> tmpfile$$

/usr/sbin/sendmail -i -- toemail < tmpfile$$

另外,在这种情况下,我通常使用 sendmail 的-t标志,而不是重复收件人:

/usr/sbin/sendmail -i -t < tmpfile$$

如果你不想使用临时文件,如果你想使用纯管道,你可以使用( )创建一个子shell来进行构建:

(
echo "To: toemail"
echo "Subject: Test"
echo "X-APP-VOLT: Yes"
echo
echo "Hope this works!"
echo
uuencode filename < file
) | /usr/sbin/sendmail -i -t

(当然,现在大多数收件人可能会发现处理 MIME 附件比处理 uuencode 更容易。使用 shell 脚本创建 MIME 附件也非常简单。)

于 2015-06-25T14:41:03.457 回答