linux - Sendmail bash 脚本读取文本文件并添加超链接
问题描述
下面是我的部分脚本。我可以使用它发送电子邮件,我唯一的问题是当我阅读文本文件(body.txt)时它会忽略新行,因为我的正文电子邮件会发送一大行。
如果我删除
Mime-version:1.0
Content-type:text/html"
比我理解文本文件上的新行。然而这次通过超链接因为纯文本,当我想成为html时。
links=<a href='deleteserid=test@gmail.com'>Unsubscribe</a>
xmail="/usr/sbin/sendmail"
# Fetches subject.txt generated from input.php page.
xsub=$(cat /data3/sss/subject.txt)
# Show from in email.
xfrom="xxx.net"
# Fetches body.txt generated from input.php page.
xmsg=$(cat /data3/ssss/body.txt)
text="$xmsg <br><br> $links"
echo $text
### Compose emails one at a time, per loop.
"$xmail" "$line" << EOF
subject:$xsub
from:$xfrom
Mime-version:1.0
Content-type:text/html
$text
EOF
解决方案
根据
[https://stackoverflow.com/questions/3902455/mail-multipart-alternative-vs-multipart-mixed]
发送 HTML 电子邮件时设置为Content-Type
。multipart/alternative
推荐阅读
- mysql - TypeORM QueryRunner 选择不同的
- python - 任何 python 包来加速循环计算?
- reactjs - 无法读取未定义的属性
- javascript - 从正则表达式模式中删除 ips,js
- intellij-idea - IntelliJ IDEA - 没有导出 IDE 设置菜单项
- javascript - 保持元素滚动到底部
- java - 如何为 CompletableFuture 设置完成或失败?
- php - 如何从 CodeIgniter 中的自定义库加载模型以检查数据库中是否存在值?
- android-studio - Ninja CMAKE_MAKE_PROGRAM 的 ndk 构建错误未设置
- c# - if 子句中的可选空合并