Wednesday 22 November 2017

linux - Sendmail command to send a file as an email body as well as attachment

I want to send an email using sendmail command in
bash. The email should get it's body by reading
Input_file_HTML and it should send same input file as an
attachment too. To do so I have tried the
following:



sendmail_touser()
{
cat - ${Input_file_HTML} << EOF | /usr/sbin/sendmail -oi
-t
From: ${MAILFROM}
To: ${MAILTO}
Subject:
$1
Content-Type: text/html; charset=us-ascii
cat
${Input_file_HTML}

Content-Transfer-Encoding:
7bit
MIME-Version: 1.0
Content-Disposition: attachment; filename:
${Input_file_HTML}
EOF
}


The
above command is giving an email with only the attachment of
Input_file_HTML and it is not writing it in the body of email.
Could you please help/guide me on same? I am using outlook as the email client. I have
even removed the cat command in above command, but it also is
not working.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...