I'm using mailx and sendmail functions to send mail from set of solaris machine with different versions. And the script send mail for most of the machine. Still issue is there on sending out mail for few servers. But there is no error shown while execute this script.

Script 1:

uuencode report.html report.html | mailx -s "mail subject" [email protected]

Script 2:

MAIL_FROM="[email protected]"
MAIL_TO="[email protected]"

echo "From: "$MAIL_FROM > $DOCROOT"header.txt"
echo "To: "$MAIL_TO >> $DOCROOT"header.txt"
echo "Subject:  The mail subject  " >> $DOCROOT"header.txt"
echo "Content-Type: text/html" >> $DOCROOT"header.txt"

cat $DOCROOT"header.txt" $DOCROOT"report.html" | /usr/lib/sendmail -t

Simply is there any way to find the error or logs of the mail delivery failed to recognize the reason of failture?

  • I don't think Solaris' sendmail creates a log by default, but it may be bouncing mails back to root or some other user with delivery failures, or the mail could be stuck in the queue (check mailq as root). May 10, 2016 at 12:55
  • Does your report.html file start with a blank line? you need to have at least one blank line between the message headers and the message body. If it's your report.html doesn't start with a blank line, just add echo >> "${DOCROOT}header.txt"immediately before the cat (it doesn't hurt to do that anyway because an extra blank line is harmless). BTW sendmail should be logging to wherever facility mail is being sent on your system - probably /var/log/mail.log or similar, try grep mail /etc/syslog.conf to verify that.
    – cas
    May 10, 2016 at 13:00
  • btw, you really should put the double-quotes around the variable as i did above (i.e. "${DOCROOT}header.txt"). If the current dir contains a space or other annoying character somewhere in the path, your script will fail.
    – cas
    May 10, 2016 at 13:02
  • 1
    After running sendmail run mail and check mails from your mai server. If there is a problem with your mail it might send you a mail with a error description.
    – user17530
    May 10, 2016 at 13:05
  • @ EightBitTony mailq is return empty
    – sugunan
    May 11, 2016 at 9:30

2 Answers 2


It's been a long time since I last used sendmail on Solaris but I'm sure its -v flag will show what's going on:

    echo 'From: [email protected]'
    echo 'To: [email protected]'
    echo 'Subject: from me to you'
) | sendmail -t -v

I'm also pretty sure that mailx passes this flag onwards:

echo hello, world | mailx -v -s "mail subject" [email protected]

Check /var/log/syslog for sendmail messages. Also take a read of The ultimate Solaris sendmail troubleshooting guide which helps with differences between Solaris versions 8, 9, 10.

  • I try the verbos mode it return following path: /export/home/sugu/dead.letter. Is this giving a clue?
    – sugunan
    May 11, 2016 at 10:32
  • @sugunan I would have expected it to have given you somewhere between 5 and 35 lines of output. Are you sure it didn't? (If it did, please add those lines to your question, explaining where it came from.) May 11, 2016 at 14:00
  • No it didn't gave. Only this line came up.
    – sugunan
    May 12, 2016 at 5:20
  • mailx: unrecognized option '-v'
    – alper
    May 15, 2019 at 18:40
  • @alper using Solaris or a Linux variant? May 15, 2019 at 19:53

Here's a slightly improved version of your script. It uses $(pwd) rather than back-ticks, single-quotes around literal strings (the From and To addresses, and the subject string), double-quotes where variable interpolation is needed, and uses a heredoc for the headers rather than multiple echo lines. I like to use the string __EOF__ to delimit heredocs because it's unlikely to occur in the body of the heredoc...any arbitrary string would work as well.

Note the final blank line before the end of the heredoc - a blank line is required to separate message headers and body.

BTW, variables are interpolated inside heredocs in the same way as for double-quoted strings. You can even use command substitution $(...) in them.

#! /bin/sh


MAIL_FROM='[email protected]'
MAIL_TO='[email protected]'
$subject='The mail subject'

cat <<__EOF__ > "$header"
Subject: $subject
Content-Type: text/html


cat "$header" "$body" | /usr/lib/sendmail -t

Let me know if that fixes your problem.

BTW to answer your actual question, sendmail should be logging to wherever facility mail is being sent on your system - possibly /var/log/mail.log or similar, try grep mail /etc/syslog.conf to verify that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .