Gra*_*ant 5 linux email bash sendmail
我正在使用以下 bash 脚本发送电子邮件
#!/bin/bash
recipients="me@web.com, you@web.com"
subject="Just a Test"
from="test@test.com"
message_txt="This is just a test.\n Goodbye!"
/usr/sbin/sendmail "$recipients" << EOF
subject:$subject
from:$from
$message_txt
EOF
Run Code Online (Sandbox Code Playgroud)
但是当电子邮件到达时, $message_txt 内容会按字面形式打印,如下所示:
This is just a test.\n Goodbye!
Run Code Online (Sandbox Code Playgroud)
而不是像这样解释新行:
This is just a test.
Goodbye!
Run Code Online (Sandbox Code Playgroud)
我尝试过使用:
echo $message_txt
echo -e $message_txt
printf $message_txt
Run Code Online (Sandbox Code Playgroud)
但结果总是一样的。我哪里错了?
我究竟做错了什么?