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:
SELFDIR=`pwd`
DOCROOT=$SELFDIR"/"
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?
mailq
as root).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 yourreport.html
doesn't start with a blank line, just addecho >> "${DOCROOT}header.txt"
immediately before thecat
(it doesn't hurt to do that anyway because an extra blank line is harmless). BTWsendmail
should be logging to wherever facilitymail
is being sent on your system - probably /var/log/mail.log or similar, trygrep mail /etc/syslog.conf
to verify that."${DOCROOT}header.txt"
). If the current dir contains a space or other annoying character somewhere in the path, your script will fail.sendmail
runmail
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.