#!/bin/bash qdir="/var/spool/mqueue" ls -c1 $qdir > /tmp/listx # To stop the sendmail process so that mails are not sent # while the cron process is active, the following two lines are required. pid=`ps -ef | grep "sendmail: accepting connections" | awk '{print $2}'` kill -9 $pid # Take one file at a time and modify it if it a header file for the # outbound mail. cat /tmp/listx | while read line do # To check only the header files that are pertaining to outbound mails use # the following line a=`grep "H?P?Return-Path:" $qdir/$line | grep utiisl.co.in` if [ "$a" != "" ] then cat $qdir/$line | sed "s/HRPFD:/RPFD:/g" > $qdir/$line fi done /etc/rc.d/init.d/mailstart /usr/sbin/sendmail -q