Tuesday, September 15, 2009

SENDMAIL Notes 2 - Running Sendmail As MSP & MTA

Sendmail As Mail-Submission-Program MSP

             In MSP mode sendmail will accept messages injected in to the queue from local users, scripts or program locally and delivers the msg when the msg deliver agent MTA is available.

Starting sendmail as MSP:

#/usr/sbin/sendmail -L sm-msp-queue -Ac -q30m

-L                    = Set  the identifier used in syslog messages to the supplied tag
sm-msp-queue = Tag that denotes sendmail as running in msp queue mode, which accepts local msgs injected in to queue.
-Ac                      = instructs sendmail to use the alternate config file instead of sendmail.cf file, i.e the submit.cf file
-q30m                 = this is the queue runner, which will re run the queue after given time if the mail is delivered.

Now check the process is running successfully by
#ps -ef |grep sendmail
smmsp     3023     1  0 17:22 ?        00:00:00 sendmail: Queue runner@00:30:00 for /var/spool/clientmqueue
sm-client.pid is the file inside /var/spool/clientmqueue with the process id .

Killing /stoping the sendmail

#cat sm-client.pid
#kill `cat sm-client.pid`

so the sendmail msp will be killed

Testing the sendmail as MSP

#sendmail kiran

Now the mail will be accepted by MSP in the queue.
this wont be delivered to destination because now the MTA is not running in the machine. So it is queued under /var/spool/clientmqueue
there are 2 types of files created in the clientmqueue director
df* = file contains the message body
qf* = file contains the message headers
So while running the sendmail in MSP mode it will accepts the messages from programs/users and for delivery/relay of the mail we need MTA.

To show the details of Logging Process of the mail program
#grep -i mail /etc/syslogd.conf

Sendmail As Mail Transfer Agent - MTA

# sendmail -L sm-mta -bd -q1h

-L sm-mta  = Set  the identifier used in syslog messages to the supplied tag and name the tag as sm-mta
-bd              = Running sendmail daemon in background
-q1hr          = queue refresh happens in every 1 hr

          This will invoke sendmail as daemon and will bind to the port 25.

Now check the sendmail process in the system -
# ps -ef |grep sendmail

smmsp     4725     1  0 18:46 ?        00:00:00 sendmail: Queue runner@00:30:00 for /var/spool/clientmqueue
root      5238     1  0 19:27 ?        00:00:00 sendmail: accepting connections

    The first process concern with MSP which will accepts the messages from programs/users
    The second Process runs as MTA which will run as Mail Transfer Agent

Now create the sendmail start up script to run the sendmail on boot. Refer the online sendmail startup scripts

To Clear the queue created by MSP while MTA was down kill the sendmail with MSP and re-run the sendmail as MSP this will force sendmail MSP to submit the mails in the clientmqueue to MTA.

#kill `cat sm-client.pid`
#sendmail -L sm-msp-queue -Ac -q30m

No comments:

Post a Comment

tag ur valuable ideas below