如何通过邮件从shell脚本发送特殊字符? [英] How to send special characters via mail from a shell script?
问题描述
./ command.sh | mail -s我的主题destination@address.com - -F发件人姓名-f sender@address.com
问题是脚本生成的文本有一些特殊字符 - é,ã,ç - 因为它不是英文。收到电子邮件后,每个字符都被替换为。
现在我明白,这很可能是因为编码设置不正确。
我的 / usr / bin / mail
符号链接到 / etc / alternatives / mail
,它也符号链接到 / usr / bin / bsd-mailx
我必须在邮件头中指定自己的编码。 ( -S
不支持。)
cat myutf8-file | mail -aContent-Type:text / plain; charset = UTF-8-s我的主题me@mail.com
I have a script that runs on cron that outputs some text which we send to the 'mail' program. The general line is like this:
./command.sh | mail -s "My Subject" destination@address.com -- -F "Sender Name" -f sender@address.com
The problem is that the text generated by the script has some special characters - é, ã, ç - since it is not in english. When the e-mail is received, each character is replaced by ??.
Now I understand that this is most likely due to the encoding that is not set correctly. What is the easiest way to fix this?
My /usr/bin/mail
is symlinked to /etc/alternatives/mail
which is also symlinked to /usr/bin/bsd-mailx
I had to specify myself the encoding in the mail header. (The -S
is not supported here.)
cat myutf8-file | mail -a "Content-Type: text/plain; charset=UTF-8" -s "My Subject" me@mail.com
这篇关于如何通过邮件从shell脚本发送特殊字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!