unix终端中邮件应用主题行内的未知字符

时间:2015-12-22 22:07:23

标签: shell email unix

我已经设置了邮件应用并为FTP创建了一个shell脚本到网站服务器,然后向管理员发送电子邮件。昨晚它工作得很好。今天早上我对它进行了更改,并开始在主题行中发送两封具有不同ASCII字符的电子邮件。

#Send an email confirming update
cat /Users/rmdlp/Documents/Scripts/message.txt | mail -s “Website Update” myemail@myemail.ca

以下是我收到的电子邮件主题的摘要:

enter image description here

其他一切都很好。 " message.txt"文件在邮件的正文中,它到我的邮箱确定。

同样在发件人的列表中,正在添加此字符串:

enter image description here

我还收到一个"你收到了/ var / mail / $ USER"中的邮件,我以前没有收到过。我查看了该文件,这是它输出的一部分:

Diagnostic-Code: X-Postfix; unknown user: "update???"

--9490A103F482.1450820767/Roys-MBP.lan
Content-Description: Undelivered Message
Content-Type: message/rfc822

Return-Path: <rmdlp@Roys-MBP.lan>
Received: by Roys-MBP.lan (Postfix, from userid 501)
    id 9490A103F482; Tue, 22 Dec 2015 16:46:05 -0500 (EST)
To: rmdlp@live.ca, Update”@Roys-MBP.lan
Subject: “Website
Message-Id: <20151222214605.9490A103F482@Roys-MBP.lan>
Date: Tue, 22 Dec 2015 16:46:05 -0500 (EST)
From: rmdlp@Roys-MBP.lan (Roy Perez)

1 个答案:

答案 0 :(得分:2)

命令mail -s “Website Update”没有按照您的想法执行。 是U + 201C,LEFT DOUBLE QUOTATION MARK, "相同。与"不同,不会被shell专门处理,因此命令会在Website Update的空白处分开,从而产生“Website的主题和额外的Update”的收件人。此额外收件人被解释为Update”@<YOUR HOSTNAME>,但由于没有此类用户,因此收到的电子邮件会被退回并最终出现在您的邮箱中。沿途的所有“未知字符”都是由编码问题引起的。

这就是使用纯文本编辑器编写代码而不是文字处理器的原因。