problema con el formato sendmail y html en el cuerpo

problema con el formato sendmail y html en el cuerpo

Necesito enviar correo en unix con 2 archivos adjuntos y el asunto en formato html.

Hice lo siguiente, ayuda a recibir el archivo adjunto pero no el contenido del cuerpo en el correo

#!/bin/bash
from="[email protected]"
to="[email protected]"
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 

Contenido de mail_body.txt:

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

¿Puede ayudar a imprimir contenido html en la parte del cuerpo del correo?

Respuesta1

printf '%s\n' "…
gato $ cuerpo
"

Estehuellas dactilaresEl catcomando. No es asicorrerél.

Y si va a utilizar \nen la especificación de formato, es mejor no utilizar nuevas líneas entrecomilladas ni una única cadena masiva.

Content-Type: text/plain; charset=\"US-ASCII\"

Es bastante obvio que una parte del cuerpo designada text/plainno se interpretará como text/html. Aunque el contenido de ese archivo, tal como se proporciona, no es HTML en primer lugar.

información relacionada