email() {
  sendmail -t <<EOF
To: xyz@gmail.com
Cc: xyz@gmail.com
Subject: This is test email
Content-Type: text/html
Attachment: file1.html
<html><font size="3">Hi Team,<br>
$(cat file2.html)
This is an autogenerated email.<br>
Dev Team.<br>

we need to display the contents of file2.html as HTML format and file1.html will be send as an attachment. If we will use sendmail -at, then it throws an error saying -a illegal option. I have gone through few blogs but all are using mailx command , as in my requirement we need the email body contents should display in HTML format , I cannot use mailx command.

  • add a new line after Attachment: , note you will have only one file, which maybe displayed inline or not depending on your mail client. – Archemar Apr 12 at 4:37
  • The sendmail command does not generate content; it operates at a lower level, The Attachment header has no meaning to sendmail, and does not cause it to include the (possibly MIME-encoded) content of file1.html in the message. You will have to use some other program to produce the body and attachment-related headers of you message. – Johan Myréen Apr 12 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.