How to get HTML file as a content to mail (shell script)
I am new to shell script, I have an HTML file which contains table data. Now I need to send this file to mail.
mail -s "test" abc.com <test.html
Currently I am getting the raw HTML code for the table in mail.
I need the table content in mail as we get in Internet Explorer.
linux bash shell script
add a comment |
I am new to shell script, I have an HTML file which contains table data. Now I need to send this file to mail.
mail -s "test" abc.com <test.html
Currently I am getting the raw HTML code for the table in mail.
I need the table content in mail as we get in Internet Explorer.
linux bash shell script
1
Question previously answered here: stackoverflow.com/questions/2591755/… stackoverflow.com/questions/3317174/…
– zuazo
Jan 10 '16 at 6:37
add a comment |
I am new to shell script, I have an HTML file which contains table data. Now I need to send this file to mail.
mail -s "test" abc.com <test.html
Currently I am getting the raw HTML code for the table in mail.
I need the table content in mail as we get in Internet Explorer.
linux bash shell script
I am new to shell script, I have an HTML file which contains table data. Now I need to send this file to mail.
mail -s "test" abc.com <test.html
Currently I am getting the raw HTML code for the table in mail.
I need the table content in mail as we get in Internet Explorer.
linux bash shell script
linux bash shell script
edited Jan 10 '16 at 6:36
JakeGould
32.2k1098141
32.2k1098141
asked Jan 10 '16 at 6:15
ThejaTheja
612
612
1
Question previously answered here: stackoverflow.com/questions/2591755/… stackoverflow.com/questions/3317174/…
– zuazo
Jan 10 '16 at 6:37
add a comment |
1
Question previously answered here: stackoverflow.com/questions/2591755/… stackoverflow.com/questions/3317174/…
– zuazo
Jan 10 '16 at 6:37
1
1
Question previously answered here: stackoverflow.com/questions/2591755/… stackoverflow.com/questions/3317174/…
– zuazo
Jan 10 '16 at 6:37
Question previously answered here: stackoverflow.com/questions/2591755/… stackoverflow.com/questions/3317174/…
– zuazo
Jan 10 '16 at 6:37
add a comment |
2 Answers
2
active
oldest
votes
Try adding -a "Content-type: text/html;"
to the message like this:
mail -a "Content-type: text/html;" -s "test" abc.com <test.html
You can easily test this by running this command that echo
’s simple HTML to the mail
command:
echo "<html><b>Test</b></html>" | mail -a "Content-type: text/html;" -s "test" abc.com
Got this idea from this question and answer thread on Unix & Linux Stack Exchange as well as this similar thread on Stack Overflow.
add a comment |
If you need the html sent as attachment, then you can use the shell tool called mpack.
http://linux.die.net/man/1/mpack
EDIT FOR SAMPLE:
I as a simple user send a dummy mail to root with /etc/hosts attached:
$ mpack -s 'trx of /etc/hosts' /etc/hosts root@localhost
and as root, I'm checking my box:
# mail
Mail version 8.1.2 01/15/2001. Type ? for help.
"/var/mail/root": 1 message 1 new
& p
Message 1:
From sgombai@localhost Thu Feb 11 01:54:27 2016
Date: Thu, 11 Feb 2016 01:54:27 +0100
From: sgombai <sgombai@localhost>
Mime-Version: 1.0
To: root@localhost
Subject: trx of /etc/hosts
Content-Type: multipart/mixed; boundary="-"
This is a MIME encoded message. Decode it with "munpack"
or any other MIME reading software. Mpack/munpack is available
via anonymous FTP in ftp.andrew.cmu.edu:pub/mpack/
---
Content-Type: application/octet-stream; name="hosts"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="hosts"
Content-MD5: 9WRRh8Yr7YPb7zo1AsgwcA==
MTI3LjAuMC4xCWxvY2FsaG9zdAo5LjE1Ny4yMTQuMTc4CXZhY21mcy52YWMuaHUuaWJtLmNv
bQl2YWNtZnMKCiMgVGhlIGZvbGxvd2luZyBsaW5lcyBhcmUgZGVzaXJhYmxlIGZvciBJUHY2
IGNhcGFibGUgaG9zdHMKOjoxICAgICBsb2NhbGhvc3QgaXA2LWxvY2FsaG9zdCBpcDYtbG9v
cGJhY2sKZmUwMDo6MCBpcDYtbG9jYWxuZXQKZmYwMDo6MCBpcDYtbWNhc3RwcmVmaXgKZmYw
Mjo6MSBpcDYtYWxsbm9kZXMKZmYwMjo6MiBpcDYtYWxscm91dGVycwpmZjAyOjozIGlwNi1h
bGxob3N0cwo=
-----
So it's arrived with attachment ready to be saved/decoded by any modern mailing program.
Can you include a little more information as links are not typically acceptable as answers? Even just outlining what it is, what its prereqs are, etc. go a long way.
– Abraxas
Feb 11 '16 at 0:32
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1024194%2fhow-to-get-html-file-as-a-content-to-mail-shell-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try adding -a "Content-type: text/html;"
to the message like this:
mail -a "Content-type: text/html;" -s "test" abc.com <test.html
You can easily test this by running this command that echo
’s simple HTML to the mail
command:
echo "<html><b>Test</b></html>" | mail -a "Content-type: text/html;" -s "test" abc.com
Got this idea from this question and answer thread on Unix & Linux Stack Exchange as well as this similar thread on Stack Overflow.
add a comment |
Try adding -a "Content-type: text/html;"
to the message like this:
mail -a "Content-type: text/html;" -s "test" abc.com <test.html
You can easily test this by running this command that echo
’s simple HTML to the mail
command:
echo "<html><b>Test</b></html>" | mail -a "Content-type: text/html;" -s "test" abc.com
Got this idea from this question and answer thread on Unix & Linux Stack Exchange as well as this similar thread on Stack Overflow.
add a comment |
Try adding -a "Content-type: text/html;"
to the message like this:
mail -a "Content-type: text/html;" -s "test" abc.com <test.html
You can easily test this by running this command that echo
’s simple HTML to the mail
command:
echo "<html><b>Test</b></html>" | mail -a "Content-type: text/html;" -s "test" abc.com
Got this idea from this question and answer thread on Unix & Linux Stack Exchange as well as this similar thread on Stack Overflow.
Try adding -a "Content-type: text/html;"
to the message like this:
mail -a "Content-type: text/html;" -s "test" abc.com <test.html
You can easily test this by running this command that echo
’s simple HTML to the mail
command:
echo "<html><b>Test</b></html>" | mail -a "Content-type: text/html;" -s "test" abc.com
Got this idea from this question and answer thread on Unix & Linux Stack Exchange as well as this similar thread on Stack Overflow.
edited May 23 '17 at 12:41
Community♦
1
1
answered Jan 10 '16 at 6:35
JakeGouldJakeGould
32.2k1098141
32.2k1098141
add a comment |
add a comment |
If you need the html sent as attachment, then you can use the shell tool called mpack.
http://linux.die.net/man/1/mpack
EDIT FOR SAMPLE:
I as a simple user send a dummy mail to root with /etc/hosts attached:
$ mpack -s 'trx of /etc/hosts' /etc/hosts root@localhost
and as root, I'm checking my box:
# mail
Mail version 8.1.2 01/15/2001. Type ? for help.
"/var/mail/root": 1 message 1 new
& p
Message 1:
From sgombai@localhost Thu Feb 11 01:54:27 2016
Date: Thu, 11 Feb 2016 01:54:27 +0100
From: sgombai <sgombai@localhost>
Mime-Version: 1.0
To: root@localhost
Subject: trx of /etc/hosts
Content-Type: multipart/mixed; boundary="-"
This is a MIME encoded message. Decode it with "munpack"
or any other MIME reading software. Mpack/munpack is available
via anonymous FTP in ftp.andrew.cmu.edu:pub/mpack/
---
Content-Type: application/octet-stream; name="hosts"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="hosts"
Content-MD5: 9WRRh8Yr7YPb7zo1AsgwcA==
MTI3LjAuMC4xCWxvY2FsaG9zdAo5LjE1Ny4yMTQuMTc4CXZhY21mcy52YWMuaHUuaWJtLmNv
bQl2YWNtZnMKCiMgVGhlIGZvbGxvd2luZyBsaW5lcyBhcmUgZGVzaXJhYmxlIGZvciBJUHY2
IGNhcGFibGUgaG9zdHMKOjoxICAgICBsb2NhbGhvc3QgaXA2LWxvY2FsaG9zdCBpcDYtbG9v
cGJhY2sKZmUwMDo6MCBpcDYtbG9jYWxuZXQKZmYwMDo6MCBpcDYtbWNhc3RwcmVmaXgKZmYw
Mjo6MSBpcDYtYWxsbm9kZXMKZmYwMjo6MiBpcDYtYWxscm91dGVycwpmZjAyOjozIGlwNi1h
bGxob3N0cwo=
-----
So it's arrived with attachment ready to be saved/decoded by any modern mailing program.
Can you include a little more information as links are not typically acceptable as answers? Even just outlining what it is, what its prereqs are, etc. go a long way.
– Abraxas
Feb 11 '16 at 0:32
add a comment |
If you need the html sent as attachment, then you can use the shell tool called mpack.
http://linux.die.net/man/1/mpack
EDIT FOR SAMPLE:
I as a simple user send a dummy mail to root with /etc/hosts attached:
$ mpack -s 'trx of /etc/hosts' /etc/hosts root@localhost
and as root, I'm checking my box:
# mail
Mail version 8.1.2 01/15/2001. Type ? for help.
"/var/mail/root": 1 message 1 new
& p
Message 1:
From sgombai@localhost Thu Feb 11 01:54:27 2016
Date: Thu, 11 Feb 2016 01:54:27 +0100
From: sgombai <sgombai@localhost>
Mime-Version: 1.0
To: root@localhost
Subject: trx of /etc/hosts
Content-Type: multipart/mixed; boundary="-"
This is a MIME encoded message. Decode it with "munpack"
or any other MIME reading software. Mpack/munpack is available
via anonymous FTP in ftp.andrew.cmu.edu:pub/mpack/
---
Content-Type: application/octet-stream; name="hosts"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="hosts"
Content-MD5: 9WRRh8Yr7YPb7zo1AsgwcA==
MTI3LjAuMC4xCWxvY2FsaG9zdAo5LjE1Ny4yMTQuMTc4CXZhY21mcy52YWMuaHUuaWJtLmNv
bQl2YWNtZnMKCiMgVGhlIGZvbGxvd2luZyBsaW5lcyBhcmUgZGVzaXJhYmxlIGZvciBJUHY2
IGNhcGFibGUgaG9zdHMKOjoxICAgICBsb2NhbGhvc3QgaXA2LWxvY2FsaG9zdCBpcDYtbG9v
cGJhY2sKZmUwMDo6MCBpcDYtbG9jYWxuZXQKZmYwMDo6MCBpcDYtbWNhc3RwcmVmaXgKZmYw
Mjo6MSBpcDYtYWxsbm9kZXMKZmYwMjo6MiBpcDYtYWxscm91dGVycwpmZjAyOjozIGlwNi1h
bGxob3N0cwo=
-----
So it's arrived with attachment ready to be saved/decoded by any modern mailing program.
Can you include a little more information as links are not typically acceptable as answers? Even just outlining what it is, what its prereqs are, etc. go a long way.
– Abraxas
Feb 11 '16 at 0:32
add a comment |
If you need the html sent as attachment, then you can use the shell tool called mpack.
http://linux.die.net/man/1/mpack
EDIT FOR SAMPLE:
I as a simple user send a dummy mail to root with /etc/hosts attached:
$ mpack -s 'trx of /etc/hosts' /etc/hosts root@localhost
and as root, I'm checking my box:
# mail
Mail version 8.1.2 01/15/2001. Type ? for help.
"/var/mail/root": 1 message 1 new
& p
Message 1:
From sgombai@localhost Thu Feb 11 01:54:27 2016
Date: Thu, 11 Feb 2016 01:54:27 +0100
From: sgombai <sgombai@localhost>
Mime-Version: 1.0
To: root@localhost
Subject: trx of /etc/hosts
Content-Type: multipart/mixed; boundary="-"
This is a MIME encoded message. Decode it with "munpack"
or any other MIME reading software. Mpack/munpack is available
via anonymous FTP in ftp.andrew.cmu.edu:pub/mpack/
---
Content-Type: application/octet-stream; name="hosts"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="hosts"
Content-MD5: 9WRRh8Yr7YPb7zo1AsgwcA==
MTI3LjAuMC4xCWxvY2FsaG9zdAo5LjE1Ny4yMTQuMTc4CXZhY21mcy52YWMuaHUuaWJtLmNv
bQl2YWNtZnMKCiMgVGhlIGZvbGxvd2luZyBsaW5lcyBhcmUgZGVzaXJhYmxlIGZvciBJUHY2
IGNhcGFibGUgaG9zdHMKOjoxICAgICBsb2NhbGhvc3QgaXA2LWxvY2FsaG9zdCBpcDYtbG9v
cGJhY2sKZmUwMDo6MCBpcDYtbG9jYWxuZXQKZmYwMDo6MCBpcDYtbWNhc3RwcmVmaXgKZmYw
Mjo6MSBpcDYtYWxsbm9kZXMKZmYwMjo6MiBpcDYtYWxscm91dGVycwpmZjAyOjozIGlwNi1h
bGxob3N0cwo=
-----
So it's arrived with attachment ready to be saved/decoded by any modern mailing program.
If you need the html sent as attachment, then you can use the shell tool called mpack.
http://linux.die.net/man/1/mpack
EDIT FOR SAMPLE:
I as a simple user send a dummy mail to root with /etc/hosts attached:
$ mpack -s 'trx of /etc/hosts' /etc/hosts root@localhost
and as root, I'm checking my box:
# mail
Mail version 8.1.2 01/15/2001. Type ? for help.
"/var/mail/root": 1 message 1 new
& p
Message 1:
From sgombai@localhost Thu Feb 11 01:54:27 2016
Date: Thu, 11 Feb 2016 01:54:27 +0100
From: sgombai <sgombai@localhost>
Mime-Version: 1.0
To: root@localhost
Subject: trx of /etc/hosts
Content-Type: multipart/mixed; boundary="-"
This is a MIME encoded message. Decode it with "munpack"
or any other MIME reading software. Mpack/munpack is available
via anonymous FTP in ftp.andrew.cmu.edu:pub/mpack/
---
Content-Type: application/octet-stream; name="hosts"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="hosts"
Content-MD5: 9WRRh8Yr7YPb7zo1AsgwcA==
MTI3LjAuMC4xCWxvY2FsaG9zdAo5LjE1Ny4yMTQuMTc4CXZhY21mcy52YWMuaHUuaWJtLmNv
bQl2YWNtZnMKCiMgVGhlIGZvbGxvd2luZyBsaW5lcyBhcmUgZGVzaXJhYmxlIGZvciBJUHY2
IGNhcGFibGUgaG9zdHMKOjoxICAgICBsb2NhbGhvc3QgaXA2LWxvY2FsaG9zdCBpcDYtbG9v
cGJhY2sKZmUwMDo6MCBpcDYtbG9jYWxuZXQKZmYwMDo6MCBpcDYtbWNhc3RwcmVmaXgKZmYw
Mjo6MSBpcDYtYWxsbm9kZXMKZmYwMjo6MiBpcDYtYWxscm91dGVycwpmZjAyOjozIGlwNi1h
bGxob3N0cwo=
-----
So it's arrived with attachment ready to be saved/decoded by any modern mailing program.
edited Feb 11 '16 at 0:59
answered Feb 10 '16 at 23:13
Gombai SándorGombai Sándor
3,0551813
3,0551813
Can you include a little more information as links are not typically acceptable as answers? Even just outlining what it is, what its prereqs are, etc. go a long way.
– Abraxas
Feb 11 '16 at 0:32
add a comment |
Can you include a little more information as links are not typically acceptable as answers? Even just outlining what it is, what its prereqs are, etc. go a long way.
– Abraxas
Feb 11 '16 at 0:32
Can you include a little more information as links are not typically acceptable as answers? Even just outlining what it is, what its prereqs are, etc. go a long way.
– Abraxas
Feb 11 '16 at 0:32
Can you include a little more information as links are not typically acceptable as answers? Even just outlining what it is, what its prereqs are, etc. go a long way.
– Abraxas
Feb 11 '16 at 0:32
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1024194%2fhow-to-get-html-file-as-a-content-to-mail-shell-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Question previously answered here: stackoverflow.com/questions/2591755/… stackoverflow.com/questions/3317174/…
– zuazo
Jan 10 '16 at 6:37