Summary: Add header to the top of the body of every e-mail (sendmail)

From: zsentient (zsentient@anosc-e.5sigcmd.army.mil)
Date: Tue Aug 12 2003 - 09:43:39 EDT


Did not really find what I was looking for (the ability to add a header to all e-mails going out of a SendMail Server), but thanks to those who were kind enough to give it a shot. Looks like I will have to applications developers address the issue within each particualar application sending out e-mail...

Original post:

I know this question has been asked, but want to put it out there again
with the hope some fresh brain matter can give it a new spin.

I am trying to echo an e-mail header (not mail header, header as in
document terminolgy) to all text e-mail bodies coming from a solaris system
using a shell script that is basically wrapping /usr/lib/sendmail.

I am aware of mimedefang, but it only runs with Sendmail version 12 (at
this time I can not upgrade) and it is a little more than I actually
need...

-This is the mail command that I must use:
# /usr/ucb/mail -r "reply_address@domain.com" -s "E-Mail Subject"
"recipeint@domain.com" < ./txt_file

-Here is the script that is attempting to add (echo) "[For Official Use Only]" into the top of the body of every e-mail going out of the system. With the echo "\n[For Official Use Only]" the subject is wrongly moved to the body of the e-mail, but the header does appear; without the "\n" in the header does not appear at all:

_______________________________________________
#!/bin/sh
# Sendmail wrap script to add header and footer.
# Script is named as /usr/lib/sendmail and sendmail binary moved to
/usr/lib/sendmail.nowrap
# Permissions of script set to match original sendmail binary:
#-r-xr-sr-x 1 root other 167 Aug 5 12:48 sendmail
        {
        #echo "[For Official Use Only]"
        echo "\n[For Official Use Only]"
        cat -
        }| /usr/lib/sendmail.nowrap "$@"
_______________________________________________

B. Hutin wrote:
you may also try to cutomize the header part in /etc/mail/sendmail.cf
(lines beginning with H)

S. Sandau wrote:
In case this is an answer to your question...

When preparing a file to email (as my backup programs and such do), the
file looks like this:

Subject: message subject goes here

message body goes here
and so on
snd so on...

so that the subject is on a line by itself, with the word Subject: at
the beginning of the line, and a blan line following it...

S. Hammack wrote:
Little hard to understand what you are trying to
do, but I'll give it a shot with what I'm doing
right now with basically the same thing:

I have to have the UNCLASSIFIED//FOR OFFICIAL USE
ONLY on any emails that are auto driven, so I
have this set for my scripts, something you might
be able to use, not sure.

I use this one to check server status:

# the directory this script resides in
ADMINDIR=/export/server/apps/admin/scripts
# the next variable can be set for multiple
#addresses
MAILADD=skip@host.com

while read -r IP SRVNM
do
     if test `/usr/sbin/ping $IP |grep -c "is
alive"` -eq 0;then
     # wait 3 mins then check again
     sleep 180
     if test `/usr/sbin/ping $IP | grep -c "is
alive"` -eq 0;then
     mail $MAILADD <<EOF
 From: root@host
To: $MAILADD
Subject: (U) $SRVNM is down, better check it out

UNCLASSIFIED//FOR OFFICIAL USE ONLY

$SRVNM is not responding, check it out!!!

EOF
 
    fi
      fi

done < $ADMINDIR/mon_drv.dat
exit 0

~~~~

This sends the email out normally, then at the
top of the email is the unclass line. I use the
same format for others with the line posted at
the bottom for longer emails.

You can also use the sendmail.cf file to append
classifications to all emails.

Not sure if this was what you were looking for,
but thought I'd pass along what I use and get
away with.

L. Hecking wrote:
 This breaks digital signatures.
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:26:55 EDT