Sendmail в формате html - PullRequest
       14

Sendmail в формате html

0 голосов
/ 31 марта 2020

Мне нужно отправить письмо в unix с 2-мя вложениями и темой в формате html.

Я сделал следующее, это помогает получить вложение, но не содержимое тела письма

#!/bin/bash
from="b@b.com"
to="A@A.com"
subject="Status"
boundary="ZZ_/afg6432dfgkl.94531q"
body="mail_body.txt"
attachments=( "FiC.txt" "FiE.txt")

# Build headers
{

printf '%s\n' "From: $from
To: $to
Subject: $subject
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary=\"$boundary\"

--${boundary}
Content-Type: text/plain; charset=\"US-ASCII\"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

cat $body
"

for file in "${attachments[@]}"; do

  [ ! -f "$file" ] && echo "Warning: attachment $file not found, skipping" >&2 && continue

 #mimetype=$(get_mimetype "$file") 

  printf '%s\n' "--${boundary}
Content-Type: text/html
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"$file\"
"

  base64 "$file"
  echo
done

printf '%s\n' "--${boundary}--"

} | /usr/sbin/sendmail -t -oi 

mail_body.txt содержимое:

   echo "<html>
        <head>
        <title> Status</title>
        </head>
        "

Может помочь в получении html содержимого, напечатанного в основной части письма?

...