Saturday 30 July 2016

bash - Is it possible to send email with attachment as .xls using shell script?

#!/bin/bash



ATTACH1=file.xls
SUBJECT="subject"
FROM=me@domain.com
TO=you@domain.com
CC=them@domain.com
MIME="application/xls"
FILE=$ATTACH1
boundary="---my-unlikely-text-for-mime-boundary---$$--"
(cat <
From: $FROM
To: $TO
Subject: $SUBJECT
Date: $(date +"%a, %b %e %Y %T %z")
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="$boundary"




This email has attached the file
--$boundary
Content-Type: $MIME;name="$FILE"
Content-Disposition: attachment;filename="$FILE"

!
) | sendmail -v ${TO}

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...