title: Send an HTML email with an attachment in unix either using mail,mailx or sendmail
body: <p>I am  trying to  send  an  HTML  email  along   with  few  attachments, but i when  m  not   using 
  <strong>Content-Type: text/html</strong>
  in header then i  am  able to send  the   attachment , but HTML  part  of  the  email is   displayed as  below :-</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;p&gt;This  is  the  body  content&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>but when  m using  the<br>
  <strong>Content-Type: text/html</strong>  in header  am   able   to  see the HTML  part  of  the  email  as  below :-</p>
  
  <p>This is  the body  content</p>
  
  <p>But in this case  m not able to send the attachment.</p>
  
  <p>Below  is  the   2 sets   of   code   am  using 
  For  set  1 :- </p>
  
  <pre><code>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 "&lt;html&gt;"
  echo "&lt;body&gt;"
  echo "&lt;font face='Courier New' size='1'&gt;"
  echo "&lt;h1&gt;Hi All,&lt;/h1&gt;"
  echo "&lt;h1&gt;Below are the path  &lt;/h1&gt;"
  echo "&lt;br&gt;"
  echo "&lt;font size="4"&gt;&lt;p&gt;Thanks &amp; Regards,&lt;br /&gt;
  &lt;br /&gt;
  echo "`for f in $FILES ; do uuencode "$f" "$f" ; done `"
  ABC&lt;/p&gt;&lt;/font&gt;"
  echo "&lt;/font&gt;"
  echo "&lt;/body&gt;"
  echo "&lt;/html&gt;"
  
  ) | /usr/sbin/sendmail -t 
  </code></pre>
  
  <p>For   set  2 :- </p>
  
  <pre><code>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 "&lt;html&gt;"
  echo "&lt;body&gt;"
  echo "&lt;font face='Courier New' size='1'&gt;"
  echo "&lt;h1&gt;Hi All,&lt;/h1&gt;"
  echo "&lt;h1&gt;Below are the path  &lt;/h1&gt;"
  echo "&lt;br&gt;"
  echo "&lt;font size="4"&gt;&lt;p&gt;Thanks &amp; Regards,&lt;br /&gt;
  &lt;br /&gt;
  echo "`for f in $FILES ; do uuencode "$f" "$f" ; done `"
  ABC&lt;/p&gt;&lt;/font&gt;"
  echo "&lt;/font&gt;"
  echo "&lt;/body&gt;"
  echo "&lt;/html&gt;"
  
  ) | /usr/sbin/sendmail -t 
  </code></pre>
  
  <p>Could   someone  please  suggest  how  can  i send both  the  HTML  part  of   email  and  attachment  from unix.</p>
  
  <p>Thanks   in  advance.</p>