我想使用mailx从主机发送一个html文件,但不是将其解释为html而是将其作为文本(html代码)发送出去。有没有办法将它作为html发送?
(cat <<EOCAT
Subject: TEST email
MIME-Version: 1.0
Content-Type: text/html
Content-Disposition: inline
EOCAT
header
cat $MSGFILE
footer
) | mailx -r localhost@host.com myemail@website.com
Run Code Online (Sandbox Code Playgroud) 我想在电子邮件中以附件形式发送一个简单的文本文件。发送电子邮件时,附件丢失,而是在电子邮件正文中显示附件的内容。需要建议修复它请。
这是我的输入:
bash-4.1$ cat test.txt
HelloWorld !
bash-4.1$ uuencode test.txt test_attachment.txt|mailx -s 'testing' mail@mail.com
Run Code Online (Sandbox Code Playgroud)
这是电子邮件上的输出:
begin 664 test_attachment.txt
/2&5L;&]7;W)L9"`A(`H*
`
end
Run Code Online (Sandbox Code Playgroud) 我有一个 shell 脚本,它对我的 arch linux 系统上的一个文件夹运行 clamav 扫描,并应该通过电子邮件发送结果。这是代码:
\n\n/usr/bin/clamscan -r -i /path/to/folder | /usr/bin/mailx -A gmail -s "Clam Scan Results $(/usr/bin/date +%F)" address@gmail.com\nRun Code Online (Sandbox Code Playgroud)\n\n如果在 bash 命令行上运行,上面的一行代码可以正常工作,并且我确认在/etc/mailrc工作中配置的帐户并收到了电子邮件。但我希望它按计划运行,我设置了一个 systemd 服务单元来调用名为 ~/bin/virusscan.sh 的脚本,并设置了一个 systemd 计时器单元以在每晚凌晨 2 点触发它。管道之后的 mailx 部分始终在报告... email not sent
SystemD 执行脚本的方式有显着差异吗?
\n\n/usr/lib/systemd/system/virusscan.service
\n\n[Unit]\nDescription=Daily virus scan\n\n[Service]\nType=simple\nExecStart=/home/username/bin/virusscan.sh\n\n[Install]\nWantedBy=multi-user.target\nRun Code Online (Sandbox Code Playgroud)\n\n/usr/lib/systemd/system/virusscan.timer
\n\n[Unit]\nDescription=Execute virus scan daily at 2 AM\n\n[Timer]\nOnCalendar=*-*-* 02:00:00\nUnit=virusscan.service\n\n[Install]\nWantedBy=multi-user.target\nRun Code Online (Sandbox Code Playgroud)\n\n然后我可以立即运行该服务来测试:
\n\nsudo systemctl start virusscan \nRun Code Online (Sandbox Code Playgroud)\n\n服务运行时的状态如下:
\n\nvirusscan.service - Daily virus scan\n …Run Code Online (Sandbox Code Playgroud) 这是我尝试过的:
$ mailx -s "test email" cloud
Cc:
"again and agina"
.
EOT
Run Code Online (Sandbox Code Playgroud)
或者,
$ mailx -s "test email" cloud
Cc:
"this is the first email"
<< EOT
Run Code Online (Sandbox Code Playgroud)
但按下后Enter什么反应也没有。为什么?