0

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.

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.

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
mtkilic
  • 1,213
  • 1
  • 12
  • 28

2 Answers2

0

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
LeadingEdger
  • 604
  • 4
  • 7
0

According to

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

Set the Content-Type to multipart/alternative when sending HTML email messages.

LeadingEdger
  • 604
  • 4
  • 7