Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mail - Attachment and content in body of email - Not working

141 views
Skip to first unread message

harpre...@gmail.com

unread,
Jun 6, 2014, 9:04:13 PM6/6/14
to
Hi,

I am using below command to attach a data file (recon.csv). Also, I am trying to put the content of another html file (recon_content.html) as the body of the email.
Version: SunOS hostname 5.10 Generic_150400-02 sun4v sparc sun4v

uuencode recon.csv recon.csv | mailx -s "$(echo -e " Test \nContent-Type: text/html")" -r te...@test.com te...@test.com < recon_content.html

The email that I receive only comes with body content but with no attachment. What is wrong here?

Kenny McCormack

unread,
Jun 6, 2014, 10:53:32 PM6/6/14
to
In article <bf38a5ad-6af0-44c1...@googlegroups.com>,
What's wrong is that you aren't using 'mpack', as you should be.

--
"I heard somebody say, 'Where's Nelson Mandela?' Well,
Mandela's dead. Because Saddam killed all the Mandelas."

George W. Bush, on the former South African president who
is still very much alive, Sept. 20, 2007

Eric

unread,
Jun 7, 2014, 6:06:34 AM6/7/14
to
On 2014-06-07, Kenny McCormack <gaz...@shell.xmission.com> wrote:
> In article <bf38a5ad-6af0-44c1...@googlegroups.com>,
> <harpre...@gmail.com> wrote:
>>Hi,
>>
>>I am using below command to attach a data file (recon.csv). Also, I am
>>trying to put the content of another html file (recon_content.html) as the
>>body of the email. Version: SunOS hostname 5.10 Generic_150400-02 sun4v
>>sparc sun4v
>>
>>uuencode recon.csv recon.csv | mailx -s "$(echo -e " Test \nContent-Type:
>>text/html")" -r te...@test.com te...@test.com < recon_content.html
>>
>>The email that I receive only comes with body content but with no
>>attachment. What is wrong here?
>
> What's wrong is that you aren't using 'mpack', as you should be.

Let's start a level higher: your command line gives mailx two standard
inputs, one from uuencode via the pipe, and another from
recon_content.html via the redirect. A program can't have two standard
inputs, and it seems that the redirect wins (though which one wins may
be shell-dependent).

And Kenny is right, you need mpack (or some equivalent) to correctly
build a multipart email message.

Eric
--
ms fnd in a lbry

harpre...@gmail.com

unread,
Jun 7, 2014, 6:56:00 AM6/7/14
to
Thanks Kenny/Eric. I checked and it seems we dont have mpack or mutt or other such utilities.

Can you point me to any other way of doing this?

Thanks

Kenny McCormack

unread,
Jun 7, 2014, 7:17:17 AM6/7/14
to
In article <ba6355e5-576a-4dcb...@googlegroups.com>,
<harpre...@gmail.com> wrote:
...
>Thanks Kenny/Eric. I checked and it seems we dont have mpack or mutt or other
>such utilities.
>
>Can you point me to any other way of doing this?

http://ftp.andrew.cmu.edu/pub/mpack/

Then configure, make, make install.

--
Nov 4, 2008 - the day when everything went
from being Clinton's fault to being Obama's fault.

harpre...@gmail.com

unread,
Jun 7, 2014, 7:51:07 AM6/7/14
to
I tried something like below. This gives the attachment and content in body of email. But this is giving content of html as plain text (not in proper html format). How can I modify this code to put body as proper html format

export MAILFROM="a...@abc.com"
export MAILTO="a...@abc.com"
export SUBJECT="Test"
export BODY="test.html"
export ATTACH_CSV="test.csv"
csv_file=$( basename "$ATTACH_CSV" )
{
echo "From: $MAILFROM"
echo "To: $MAILTO"
echo "MIME-Version: 1.0"
echo "Subject: $SUBJECT"
echo "Content-Type: multipart/mixed; boundary=\"FILEBOUNDARY\""

echo "--FILEBOUNDARY"
echo "Content-Type: multipart/alternative; boundary=\"MSGBOUNDARY\""

echo "--MSGBOUNDARY"
echo "Content-Type: text/html; charset=iso-8859-1"
echo "Content-Disposition: inline"
cat "$BODY"
echo "--MSGBOUNDARY--"

echo "--FILEBOUNDARY"
echo "Content-Type: text/csv"
echo "Content-Disposition: inline; filename=\"${csv_file}\""
echo "Content-Transfer-Encoding: uuencode"
uuencode "$ATTACH_CSV" "$csv_file"
echo "--FILEBOUNDARY--"
} | /usr/sbin/sendmail -t

Thanks

On Friday, June 6, 2014 9:04:13 PM UTC-4, harpre...@gmail.com wrote:

harpre...@gmail.com

unread,
Jun 7, 2014, 7:52:12 AM6/7/14
to
Thanks Kenny. But this is a prod box. I canno just install anything. Sorry, but hope you understand

Kaz Kylheku

unread,
Jun 7, 2014, 9:09:27 AM6/7/14
to
On 2014-06-07, harpre...@gmail.com <harpre...@gmail.com> wrote:
> Thanks Kenny/Eric. I checked and it seems we dont have mpack or mutt or other such utilities.
>
> Can you point me to any other way of doing this?

Read the RFC's about what a MIME-encoded message is supposed to look like, then
write the code to make it so:

http://tools.ietf.org/html/rfc2045
http://tools.ietf.org/html/rfc2822

Good luck!

Janis Papanagnou

unread,
Jun 7, 2014, 10:59:52 AM6/7/14
to
On 07.06.2014 13:51, harpre...@gmail.com wrote:
> I tried something like below. This gives the attachment and content in body
> of email. But this is giving content of html as plain text (not in proper
> html format). How can I modify this code to put body as proper html format

If below code is supposed to produce a mail message; I see no mail
body, just a (malformed?) header. Did you miss to create the empty
line[*] between header and body?

Janis

[*] If would probably have been easier to spot if you'd have applied
a here-doc instead of that echo storm.

harpre...@gmail.com

unread,
Jun 7, 2014, 11:56:41 AM6/7/14
to
Janis,

I am using below as the body of the email. The $BODY variable has the name of the html file.

cat $BODY

Below is the content of the HTML file

Content-Type: text/html; charset=iso-8859-1
Content-Disposition: inline
<HTML><TABLE border=1 cellpadding=3 cellspacing=3 ><TH bgcolor=#00FFFF>GIW - Filenames Sent</TH></TH><TH bgcolor=#00FFFF>Match</TH> <TR><TD ALIGN=LEFT><FONT FACE=Verdana SIZE=2>test_data3</FONT></TD><TD ALIGN=LEFT><FONT FACE=Verdana SIZE=2>NO MATCH</FONT></TD></TR> <TR><TD ALIGN=LEFT><FONT FACE=Verdana SIZE=2>test_data2</FONT></TD><TD ALIGN=LEFT><FONT FACE=Verdana SIZE=2>NO MATCH</FONT></TD></TR> <TR><TD ALIGN=LEFT><FONT FACE=Verdana SIZE=2>test_data</FONT></TD><TD ALIGN=LEFT><FONT FACE=Verdana SIZE=2>NO MATCH</FONT></TD></TR> </TABLE></BODY></HTML>

Thanks

Janis Papanagnou

unread,
Jun 7, 2014, 5:45:16 PM6/7/14
to
On 07.06.2014 17:56, harpre...@gmail.com wrote:
> Janis,
>
> I am using below as the body of the email. The $BODY variable has the name of the html file.

I supposed so. But is it including or excluding an empty line that would
be necessary to separate the mail header from the mail body?
(In other words; are the lines that I marked with ** part of the file?)

Your posting is really irritating, not only because you show the charset
and inline definitions twice, once in the echo commands of your previous
posting and now (it seems) also as part of the html-file.

Janis

>
> cat $BODY
**>
**> Below is the content of the HTML file
**>

Stewart McKenna

unread,
Jun 22, 2014, 9:17:29 AM6/22/14
to
mailx -m -s works for me

Eric

unread,
Jun 22, 2014, 12:57:41 PM6/22/14
to
If your mailx has -m, which is by no means certain - what platform are
you on?

EriC

Stewart McKenna

unread,
Jun 27, 2014, 11:01:01 PM6/27/14
to
HP-UX
0 new messages