我试图通过AutomicWorkloadAutomation12.0的bash作业使用mailx发送电子邮件。消息需要有一个特殊的字符,在这种情况下,百分比符号"°“。
对于这个例子,消息应该有主体This is the ° sign.。
我正在使用这段代码来发送消息。printf '\xB0'打印°符号。
(
printf 'This is the '
printf '\xB0'
printf ' sign.'
) | mailx [etc]如果我直接将其复制并粘贴到bash终端中,则电子邮件将很好地发送到邮件正文中打印的特殊字符。
但是,当我在Automic作业中使用相同的代码时,电子邮件正文是空的。有一个附加的文件,名为ATT00001.bin。如果我使用ATT00001.bin打开notepad.exe,文件中包含的文本应该在正文中,This is the ° sign.中的字符与正文中应该打印的字符完全相同。
当在Automic中使用以下内容时,将以正确的正文发送消息。没有附加文件。因此,很明显,这个特殊的字符是导致这个问题与Automic。
(
printf 'This is the '
printf 'placeholder'
printf ' sign.'
) | mailx [etc]有没有人知道为什么会发生这种情况,或者如何解决?
发布于 2017-09-15 10:35:46
Mailx是一种进化的MUA。如果使用sendmail,只需发送邮件,就可以构建自己的邮件头:
/usr/sbin/sendmail destuser@desthost <<eomail
To: destuser@desthost
Subject: Any interesting thing
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
This is the ° sign
eomail或者您可以使用html编码:
/usr/sbin/sendmail destuser@desthost <<eomail
To: destuser@desthost
Subject: Any interesting thing
MIME-Version: 1.0
Content-Type: text/html; charset="ASCII"
Content-Transfer-Encoding: 8bit
<html><body>This is the ° sign</body></html>
eomail小心,只使用ASCII字符那里!
https://stackoverflow.com/questions/46227403
复制相似问题