2

I am trying to send an HTML email along with few attachments, but i when m not using Content-Type: text/html in header then i am able to send the attachment , but HTML part of the email is displayed as below :-

<html>
<body>
<p>This  is  the  body  content</p>
</body>
</html>

but when m using the
Content-Type: text/html in header am able to see the HTML part of the email as below :-

This is the body content

But in this case m not able to send the attachment.

Below is the 2 sets of code am using For set 1 :-

FILES="$(ls /dir_with_the_list_of_files_to_be_sent  | awk  '{print $0}' | tr '\n' ' ')"  
(
echo "To: abc@abc.com"
echo "Subject:Extract List ";
echo "Content-Type: text/html"
echo
echo "<html>"
echo "<body>"
echo "<font face='Courier New' size='1'>"
echo "<h1>Hi All,</h1>"
echo "<h1>Below are the path  </h1>"
echo "<br>"
echo "<font size="4"><p>Thanks & Regards,<br />
<br />
echo "`for f in $FILES ; do uuencode "$f" "$f" ; done `"
ABC</p></font>"
echo "</font>"
echo "</body>"
echo "</html>"

) | /usr/sbin/sendmail -t 

For set 2 :-

FILES="$(ls /dir_with_the_list_of_files_to_be_sent  | awk  '{print $0}' | tr '\n' ' ')"  
(
echo "To: abc@abc.com"
echo "Subject:Extract List ";
echo
echo "<html>"
echo "<body>"
echo "<font face='Courier New' size='1'>"
echo "<h1>Hi All,</h1>"
echo "<h1>Below are the path  </h1>"
echo "<br>"
echo "<font size="4"><p>Thanks & Regards,<br />
<br />
echo "`for f in $FILES ; do uuencode "$f" "$f" ; done `"
ABC</p></font>"
echo "</font>"
echo "</body>"
echo "</html>"

) | /usr/sbin/sendmail -t 

Could someone please suggest how can i send both the HTML part of email and attachment from unix.

Thanks in advance.

  • You can't just print attachments into the message. You need to use multipart, see for example this https://stackoverflow.com/questions/17097806/send-email-via-smtp-with-attachment-plain-text-and-text-hml – James Z Oct 29 '17 at 19:42
  • Thanks James... But it seems in unix its not possible to send multiple attachments along with HTML. I tried an alternative and zipped the files to be sent and then used sendmail to send the emal with one zip attachment – Bhanupratap Singh Oct 30 '17 at 11:51
  • I'm quite sure there is no such limitation. You should update your question with the latest code. – James Z Oct 30 '17 at 16:09
  • Hi,Thanks for helping on my question. – Bhanupratap Singh Mar 13 '18 at 08:20

0 Answers0