3

The code below is a shell script which is working for one attachment, I need to send second attachment in the same email but that should be in text/plain. both need to go as body text in the email. Please advice.

I have tried the below and is working for one attachment, need to embed the second attachment in the same email as message body plain text.

cat <<'EOF' - /usr/local/oracle/wls1036/owbmonitor/owbmonitor.log | /usr/sbin/sendmail -t
To:s.a@yahoo.com
Subject: PREPROD MONITOR ${DATE}
Content-Type: text/html
EOF

As per the suggestion to use multiform types:, I have tried the below which is not working

(
cat <<!
Subject: OWB PREPROD MONITOR AT ${DATE}
To: s.ad@yahoo.com.com
MIME-Version: 1.0
Content-Type: multipart/mixed;boundary="nextfile"
--nextfile
Content-Type: text/html
`cat /usr/local/oracle/wls1036/domains/mydomain/bin/owbmonitor/owbmonitor.log`
--nextfile
Content-Type: text/plain
`cat /usr/local/oracle/wls1036/domains/mydomain/bin/owbmonitor/top.log`
!
) | /usr/sbin/sendmail -t
shellter
  • 36,525
  • 7
  • 83
  • 90
SSA
  • 73
  • 1
  • 9
  • did you try `...;boundary="--nextfile"` ? Good luck. – shellter Apr 27 '14 at 13:33
  • Your here document contains several formatting errors in the MIME structure. You need an empty line between the body part headers and the body part body (sic) after each part boundary, and you are missing a final closing boundary. It's not hard to find correct examples; https://stackoverflow.com/questions/902591/how-to-attach-a-file-using-mail-command-on-linux has one. – tripleee Jan 26 '18 at 05:15
  • mailx is way easier to use then sendmail: echo $message_body | mailx -s "Your Subject" -a attach_file1.ext -a attach_file2.ext user@mydomain.com – GaryB Aug 11 '20 at 02:36

0 Answers0