mail format problems

Hi,

I have a script that runs off the cron and creates a report, carries out a few checks and then sends the info in a email (i'm using mailx).

To exectute the sending from the script all I do is,

cat $reportfile | mailx -s "The Subject" my.email@work.com

When I test running this script manually (not via the cron) the report appears as the content of the email not as an attachment. This is what I want.

When I run it in the cron the mail arrives with an attachment (this has the report) and the email contains messages about unsupported charecter set not suported by the Internet service.

How can running this from cron (same user) give different results to running from the command line?

HPUX
sh script.

Many thanks,
Neil :confused:

it should not be an attachment at all. the contents will be the body of the email.

my guess is something is going wrong with the inital process and is sending it as an error attachment.

now what the error would be i have no clue.

mailx reads initialization commands first from /usr/share/lib/mailx.rc and then from $HOME/.mailrc. But the second file can't be read if HOME is not set. Could your cron job have clobbered the HOME variable? cron will set HOME by default.

but to give mailx an attachment you have to use uuencode to do that. mailx does not have any built in functions to handle sending attachments.

The only time i get attachments (when i do not specify to attach something) is when there was an error sending blah mail and it is rejected for somereason or another and the mail comes back to the user that sent it.

The issue is that HP-UX does not use ascii by default for mail. So you need to feed a line like:
set charset=us-ascii
to mailx in one of those start up files. If this is not done, a non-ascii mail message goes out. And microsoft user agents freak out and deliver it as an attachment.