简体   繁体   English

Sendmail bash 脚本读取文本文件并添加超链接

[英]Sendmail bash script read text file and add hyperlink

Below I have partial of my script.下面是我的部分脚本。 I can send email using this, my only problem is when I read text file (body.txt) it ignores new lines, because of that my body email send one big line.我可以使用这个发送 email,我唯一的问题是当我阅读文本文件(body.txt)时它会忽略新行,因为我的身体 email 发送一大行。

if I remove如果我删除

Mime-version:1.0
Content-type:text/html"

Than I it does understand new line on text file.比我理解文本文件上的新行。 However this time by hyperlinks because plain text, when I want to be 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

Instead of:代替:

...
Content-type:text/html
$text
EOF

Replace it with:将其替换为:

...
Content-type:text/html
$(cat /data3/ssss/body.txt)
$xmsg <br><br> $links
EOF

According to根据

[https://stackoverflow.com/questions/3902455/mail-multipart-alternative-vs-multipart-mixed] [https://stackoverflow.com/questions/3902455/mail-multipart-alternative-vs-multipart-mixed]

Set the Content-Type to multipart/alternative when sending HTML email messages.发送 HTML email 消息时,将Content-Type设置为multipart/alternative

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM