Send mail with an attachment and body of mail with table format

Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I need to send a mail with an attachment and body of mail in table format.I have used the below code to send mail. but unable to attache file.
(echo "From: ";
echo "Subject: testing of table using awk";
echo "Content-type: text/html";
echo;
awk 'BEGINprint "<table>" print "<tr><tr>";for(i=1;i<=NF;i++)print "<td><td>" $i"</td></td>";print "</tr></tr>" ENDprint "</table>"' input1.txt;
) | sendmail xxx@yyy.com
linux sendmail
add a comment |Â
up vote
2
down vote
favorite
I need to send a mail with an attachment and body of mail in table format.I have used the below code to send mail. but unable to attache file.
(echo "From: ";
echo "Subject: testing of table using awk";
echo "Content-type: text/html";
echo;
awk 'BEGINprint "<table>" print "<tr><tr>";for(i=1;i<=NF;i++)print "<td><td>" $i"</td></td>";print "</tr></tr>" ENDprint "</table>"' input1.txt;
) | sendmail xxx@yyy.com
linux sendmail
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I need to send a mail with an attachment and body of mail in table format.I have used the below code to send mail. but unable to attache file.
(echo "From: ";
echo "Subject: testing of table using awk";
echo "Content-type: text/html";
echo;
awk 'BEGINprint "<table>" print "<tr><tr>";for(i=1;i<=NF;i++)print "<td><td>" $i"</td></td>";print "</tr></tr>" ENDprint "</table>"' input1.txt;
) | sendmail xxx@yyy.com
linux sendmail
I need to send a mail with an attachment and body of mail in table format.I have used the below code to send mail. but unable to attache file.
(echo "From: ";
echo "Subject: testing of table using awk";
echo "Content-type: text/html";
echo;
awk 'BEGINprint "<table>" print "<tr><tr>";for(i=1;i<=NF;i++)print "<td><td>" $i"</td></td>";print "</tr></tr>" ENDprint "</table>"' input1.txt;
) | sendmail xxx@yyy.com
linux sendmail
edited May 16 at 19:21
asked Mar 7 at 17:14
SivaPrasath
6,23143255
6,23143255
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
Try to use a version of mail command supporting -a (attachment) switch . It's the more reliable solution.
s-nail have it !
email=foo@base
mail -v -s subject foo@bar -a file.txt -q - <<EOF
$(awk '
BEGINprint "<table>"
print "<tr><tr>";
for(i=1;i<=NF;i++)
print "<td><td>" $i"</td></td>";
print "</tr></tr>";
ENDprint "</table>"' input1.txt
)
.
EOF
Check man mail if you need to add headers and such
i need body of mail with table format as well...
â SivaPrasath
Mar 7 at 17:44
mail command is not converting to table format. it is printing with html tags..
â SivaPrasath
Mar 7 at 17:56
Sure, you need to read theman mailto add headers as already said
â Gilles Quenot
Mar 7 at 18:26
add a comment |Â
up vote
0
down vote
accepted
Using sendmail:
TO_ADDRESS="abc@example.com"
SUBJECT="Test Mail"
cat << --OEF--
Subject: $SUBJECT
TO: $TO_ADDRESS
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="MAIL_BOUNDARY"
--MAIL_BOUNDARY
Content-Type: multipart/alternative;
boundary="MAIL_BOUNDARY2"
--MAIL_BOUNDARY2
Content-Type: text/plain; charset=utf-8
$SUBJECT
--MAIL_BOUNDARY2
Content-Type: text/html; charset=utf-8
--OEF--
cat MailBody.html
cat << --OEF--
--MAIL_BOUNDARY2--
--MAIL_BOUNDARY
Content-Type: application/zip; name=file.zip
Content-Disposition: attachment; filename=file.zip
Content-Transfer-Encoding: base64
--OEF--
base64 /opt/file.zip
cat << --OEF--
--MAIL_BOUNDARY--
--OEF--
) | /usr/sbin/sendmail $TO_ADDRESS
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Try to use a version of mail command supporting -a (attachment) switch . It's the more reliable solution.
s-nail have it !
email=foo@base
mail -v -s subject foo@bar -a file.txt -q - <<EOF
$(awk '
BEGINprint "<table>"
print "<tr><tr>";
for(i=1;i<=NF;i++)
print "<td><td>" $i"</td></td>";
print "</tr></tr>";
ENDprint "</table>"' input1.txt
)
.
EOF
Check man mail if you need to add headers and such
i need body of mail with table format as well...
â SivaPrasath
Mar 7 at 17:44
mail command is not converting to table format. it is printing with html tags..
â SivaPrasath
Mar 7 at 17:56
Sure, you need to read theman mailto add headers as already said
â Gilles Quenot
Mar 7 at 18:26
add a comment |Â
up vote
2
down vote
Try to use a version of mail command supporting -a (attachment) switch . It's the more reliable solution.
s-nail have it !
email=foo@base
mail -v -s subject foo@bar -a file.txt -q - <<EOF
$(awk '
BEGINprint "<table>"
print "<tr><tr>";
for(i=1;i<=NF;i++)
print "<td><td>" $i"</td></td>";
print "</tr></tr>";
ENDprint "</table>"' input1.txt
)
.
EOF
Check man mail if you need to add headers and such
i need body of mail with table format as well...
â SivaPrasath
Mar 7 at 17:44
mail command is not converting to table format. it is printing with html tags..
â SivaPrasath
Mar 7 at 17:56
Sure, you need to read theman mailto add headers as already said
â Gilles Quenot
Mar 7 at 18:26
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Try to use a version of mail command supporting -a (attachment) switch . It's the more reliable solution.
s-nail have it !
email=foo@base
mail -v -s subject foo@bar -a file.txt -q - <<EOF
$(awk '
BEGINprint "<table>"
print "<tr><tr>";
for(i=1;i<=NF;i++)
print "<td><td>" $i"</td></td>";
print "</tr></tr>";
ENDprint "</table>"' input1.txt
)
.
EOF
Check man mail if you need to add headers and such
Try to use a version of mail command supporting -a (attachment) switch . It's the more reliable solution.
s-nail have it !
email=foo@base
mail -v -s subject foo@bar -a file.txt -q - <<EOF
$(awk '
BEGINprint "<table>"
print "<tr><tr>";
for(i=1;i<=NF;i++)
print "<td><td>" $i"</td></td>";
print "</tr></tr>";
ENDprint "</table>"' input1.txt
)
.
EOF
Check man mail if you need to add headers and such
edited Mar 7 at 18:27
answered Mar 7 at 17:21
Gilles Quenot
15.3k13448
15.3k13448
i need body of mail with table format as well...
â SivaPrasath
Mar 7 at 17:44
mail command is not converting to table format. it is printing with html tags..
â SivaPrasath
Mar 7 at 17:56
Sure, you need to read theman mailto add headers as already said
â Gilles Quenot
Mar 7 at 18:26
add a comment |Â
i need body of mail with table format as well...
â SivaPrasath
Mar 7 at 17:44
mail command is not converting to table format. it is printing with html tags..
â SivaPrasath
Mar 7 at 17:56
Sure, you need to read theman mailto add headers as already said
â Gilles Quenot
Mar 7 at 18:26
i need body of mail with table format as well...
â SivaPrasath
Mar 7 at 17:44
i need body of mail with table format as well...
â SivaPrasath
Mar 7 at 17:44
mail command is not converting to table format. it is printing with html tags..
â SivaPrasath
Mar 7 at 17:56
mail command is not converting to table format. it is printing with html tags..
â SivaPrasath
Mar 7 at 17:56
Sure, you need to read the
man mail to add headers as already saidâ Gilles Quenot
Mar 7 at 18:26
Sure, you need to read the
man mail to add headers as already saidâ Gilles Quenot
Mar 7 at 18:26
add a comment |Â
up vote
0
down vote
accepted
Using sendmail:
TO_ADDRESS="abc@example.com"
SUBJECT="Test Mail"
cat << --OEF--
Subject: $SUBJECT
TO: $TO_ADDRESS
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="MAIL_BOUNDARY"
--MAIL_BOUNDARY
Content-Type: multipart/alternative;
boundary="MAIL_BOUNDARY2"
--MAIL_BOUNDARY2
Content-Type: text/plain; charset=utf-8
$SUBJECT
--MAIL_BOUNDARY2
Content-Type: text/html; charset=utf-8
--OEF--
cat MailBody.html
cat << --OEF--
--MAIL_BOUNDARY2--
--MAIL_BOUNDARY
Content-Type: application/zip; name=file.zip
Content-Disposition: attachment; filename=file.zip
Content-Transfer-Encoding: base64
--OEF--
base64 /opt/file.zip
cat << --OEF--
--MAIL_BOUNDARY--
--OEF--
) | /usr/sbin/sendmail $TO_ADDRESS
add a comment |Â
up vote
0
down vote
accepted
Using sendmail:
TO_ADDRESS="abc@example.com"
SUBJECT="Test Mail"
cat << --OEF--
Subject: $SUBJECT
TO: $TO_ADDRESS
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="MAIL_BOUNDARY"
--MAIL_BOUNDARY
Content-Type: multipart/alternative;
boundary="MAIL_BOUNDARY2"
--MAIL_BOUNDARY2
Content-Type: text/plain; charset=utf-8
$SUBJECT
--MAIL_BOUNDARY2
Content-Type: text/html; charset=utf-8
--OEF--
cat MailBody.html
cat << --OEF--
--MAIL_BOUNDARY2--
--MAIL_BOUNDARY
Content-Type: application/zip; name=file.zip
Content-Disposition: attachment; filename=file.zip
Content-Transfer-Encoding: base64
--OEF--
base64 /opt/file.zip
cat << --OEF--
--MAIL_BOUNDARY--
--OEF--
) | /usr/sbin/sendmail $TO_ADDRESS
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Using sendmail:
TO_ADDRESS="abc@example.com"
SUBJECT="Test Mail"
cat << --OEF--
Subject: $SUBJECT
TO: $TO_ADDRESS
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="MAIL_BOUNDARY"
--MAIL_BOUNDARY
Content-Type: multipart/alternative;
boundary="MAIL_BOUNDARY2"
--MAIL_BOUNDARY2
Content-Type: text/plain; charset=utf-8
$SUBJECT
--MAIL_BOUNDARY2
Content-Type: text/html; charset=utf-8
--OEF--
cat MailBody.html
cat << --OEF--
--MAIL_BOUNDARY2--
--MAIL_BOUNDARY
Content-Type: application/zip; name=file.zip
Content-Disposition: attachment; filename=file.zip
Content-Transfer-Encoding: base64
--OEF--
base64 /opt/file.zip
cat << --OEF--
--MAIL_BOUNDARY--
--OEF--
) | /usr/sbin/sendmail $TO_ADDRESS
Using sendmail:
TO_ADDRESS="abc@example.com"
SUBJECT="Test Mail"
cat << --OEF--
Subject: $SUBJECT
TO: $TO_ADDRESS
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="MAIL_BOUNDARY"
--MAIL_BOUNDARY
Content-Type: multipart/alternative;
boundary="MAIL_BOUNDARY2"
--MAIL_BOUNDARY2
Content-Type: text/plain; charset=utf-8
$SUBJECT
--MAIL_BOUNDARY2
Content-Type: text/html; charset=utf-8
--OEF--
cat MailBody.html
cat << --OEF--
--MAIL_BOUNDARY2--
--MAIL_BOUNDARY
Content-Type: application/zip; name=file.zip
Content-Disposition: attachment; filename=file.zip
Content-Transfer-Encoding: base64
--OEF--
base64 /opt/file.zip
cat << --OEF--
--MAIL_BOUNDARY--
--OEF--
) | /usr/sbin/sendmail $TO_ADDRESS
answered May 16 at 17:39
SivaPrasath
6,23143255
6,23143255
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f428805%2fsend-mail-with-an-attachment-and-body-of-mail-with-table-format%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password