1

File is not attached while send in HTML email Bash

Below is my sample script ,while executing the script the mail was sent with out an attachment. Please help.

#!/bin/bash
FOUND_EMAIL_TEXT="This is an automated report generated .
Please investigate and remediate them as soon as possible."
 (
             echo "From: [email protected]"
             echo "To: [email protected]"
             echo "MIME-Version: 1.0"
             echo "Subject: Test Email"
             echo "Content-Type: text/html"
             echo "<FONT FACE='COURIER NEW' SIZE='5'>;<PRE>"
             echo -e "${FOUND_EMAIL_TEXT}
             echo "</PRE><;/FONT>;"
             echo "Content-Type: text/html"
             echo 'Content-Disposition: attachment; filename="'/ght.txt/'"'
                echo "$(cat /home/dfg/ter.txt)"
) | sendmail -t 
Renga
  • 393
  • 2
  • 10
  • You have a missing quote on the `echo -e "${FOUND_EMAIL_TEXT}` line. Is that a typo here in your question or is it part of your script? – terdon Sep 12 '20 at 11:54
  • Typo here,just corrected it. – Renga Sep 12 '20 at 12:29
  • Does this answer your question? [What are some better options for encoding email attachments than uuencode in a bash script?](https://unix.stackexchange.com/questions/378066/what-are-some-better-options-for-encoding-email-attachments-than-uuencode-in-a-b) – roaima Sep 12 '20 at 12:32
  • In the proposed duplicate take a particular look at the [answer recommending `mpack`](https://unix.stackexchange.com/a/378081/100397) – roaima Sep 12 '20 at 12:33
  • Actually, I think this one's a better fit for duplicate status - [How to send email with both a body and attachment](https://unix.stackexchange.com/q/309052/100397) – roaima Sep 12 '20 at 12:34

0 Answers0