cancel
Showing results for 
Search instead for 
Did you mean: 

Garbage using sendmail

ROSS HANSON
Regular Advisor

Garbage using sendmail

Hello
I am writing a script to send, through sendmail, a Ascii file to certain people. Here is the script:
SENDMAIL=/usr/sbin/sendmail
UUENCODE=/usr/bin/uuencode
USER_LIST="garvin"
DOMAIN=my.domain.com
LOG_FILE=/var/log/messages
#
for USER in $USER_LIST
#
do
#
echo "Subject: Output Log $0 \n` cat $LOG_FILE | $UUENCODE $LOG_FILE`" | $SENDMAIL $USER@$DOMAIN
#
done

I can receive the email but:
1. "To" line shows 'undisclosed-recipients:;
2. "Subject" line shows ./send2.test (this is the name of the script I am running) then \nbegin 644 /var/log/messages
3. As far as what is to be attached... comes up M07!R(#$Q(#`T.C$U.C$Y('1H;V]S83$@M="X*07!R(#$Q(#`T.C$U.C$Y('1H;V]S83$@M(&]N(&YO;F4*07!R(#$Q(#`T.C$U.C$Y('1H;V]S83$@M,CH@M"D%P#(Z('-E
This isn't all but you get the idea.

As you can see from the script we are using sendmail and postfix is the engine underneath

If possible I don't wish to use mutt or anything else. This script works well in HPUX
but what's the big difference in SLES 9?

Thanks
Ross Hanson
4 REPLIES
Steven Schweda
Honored Contributor

Re: Garbage using sendmail

> what's the big difference in SLES 9?

Not the best question for an HP-UX forum?

"man sendmail" may show its command-line
options. The "sendmail" program itself and
its configuration tend to differ among
different systems.

The stuff with "M" at the beginning of each
line is what you get out of "uuencode".
What's your complaint about that?

On HP-UX, I'd tend to use "mailx" instead of
"sendmail" for this sort of thing, but many
things are possible.
Steven E. Protter
Exalted Contributor

Re: Garbage using sendmail

Shalom,

If you are using an stmp relay it could be making your mail into garbage.

Otherwise compare your script to a production working script and see if there is something that helps.

http://www.hpux.ws/mailfile1

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
ROSS HANSON
Regular Advisor

Re: Garbage using sendmail

Sep,
The url you have sent does not work. I received:
Not Found

The requested URL /mailfile1 was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Does it work on your end?
Ross Hanson
Tor-Arne Nostdal
Trusted Contributor

Re: Garbage using sendmail

In SLES the echo command does not work like in HP-UX.
Perhaps this helps:
#!/bin/sh
SENDMAIL=/usr/sbin/sendmail
UUENCODE=/usr/bin/uuencode
USER_LIST="garvin"
DOMAIN=my.domain.com
LOG_FILE=/var/log/messages
#
for USER in $USER_LIST
do
{ echo "Subject: Output Log $0"
echo "To: $USER@$DOMAIN"
cat $LOG_FILE | $UUENCODE $LOG_FILE
} | $SENDMAIL -t
done

#------------------------------------
It might be better not to uuencode the message and rather settle for a more detailed mail header and files which have been processed a bit in advance.

Here is some lines to study and give some ideas...
#-----------------------------------------
BODYTXT="/tmp/mailbody.$$"
CSVREPOT="/tmp/report.$$"
#
# some script to generate mailbody and CSV report files
#

# Then send the mail with the CSV report as attachment named "datasheet.csv"
echo "Subject: My Subject"
echo "To: $RECIPIENTS "
echo "Reply-To: $REPLYTO"
echo "Mime-Version: 1.0"
echo "Content-Type: multipart/mixed; boundary=\"boundary-line\""
echo "\nThis is a MIME multipart mail message.\n"
echo "--boundary-line"
echo "Content-Type: text/html; charset=us-ascii\n"
cat -v $NOTTXT
echo "\n--boundary-line"
echo "Content-Type: application/ms-excel;"
echo " name=\"datasheet.csv\""
echo "Content-Transfer-Encoding: us-ascii"
echo "Content-Disposition: attachment;"
echo " filename=\"datasheet.csv\"\n"
sleep 1
cat -v $REPFILE
} | sendmail -t

#----------------------------------------
Some more lines if you would like to pipe to a notification script

#! /bin/sh
# Script to forward mail with sendmail
#
# How it works:
# This script will use the parameters to define subject and recipients.
# All standard input will be added as mailbody
# The mail is sent by user: sysadmin
#
# Usage: notify {your subject} : {comma separated recipients}
LINE="$*"
SUBJECT="$(echo "${LINE}"|cut -d: -f1)"
RECIPIENTS="$(echo "${LINE}"|cut -d: -f2)"
# Send mail to specified recipient
{ echo "Subject: $SUBJECT"
echo "To: $RECIPIENTS "
echo "Reply-To: sysadmin@my.domain"
echo 'MIME-Version: 1.0'
echo 'Content-Type: text/html; charset=us-ascii'
cat
} | su - sysadmin -c "sendmail -t" 1>/dev/null 2>&1

# ---------------------------------


Hope this helps

/Tor-Arne
I'm trying to become President of the state I'm in...