DISCLAIMER : Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility.If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.


Showing posts with label sendmail. Show all posts
Showing posts with label sendmail. Show all posts

work with sendmail in AIX

Sendmail has been included with the AIX operating system for many years now.
Despite its reputation for being difficult to administer, it is very powerful and can perform some interesting tricks. It's helped me overcome some challenges over the years.
This article shares two interesting tricks that I discovered with Sendmail on AIX.
 

To start the Sendmail daemon, use the startsrc command. For example:

# startsrc -s sendmail -a "-bd -q30m"

The –s flag specifies the subsystem to start, and the –a flag instructs startsrc to execute the subsystem with the specified arguments.
The -bd flag starts Sendmail as a daemon (running in the background) as a Simple Mail Transfer Protocol (SMTP) mail router. The –q flag specifies the interval at which the Sendmail daemon processes saved messages in the mail queue. In this example, Sendmail will process the mail queue every 30 minutes.

To start the Sendmail daemon automatically on a reboot, uncomment the following line in the /etc/rc.tcpip file:
# vi /etc/rc.tcpip
start /usr/lib/sendmail "$src_running" "-bd -q${qpi}"

Execute the following command to display the status of the Sendmail daemon:
# lssrc -s sendmail

To stop Sendmail, use stopsrc:
# stopsrc -s sendmail

The Sendmail configuration file is located in the /etc/mail/sendmail.cf file, and the Sendmail mail alias file is located in /etc/mail/aliases.
If you add an alias to the /etc/mail/aliases file, remember to rebuild the aliases database and run the sendmail command with the -bi flag or the /usr/sbin/newaliases command. This forces the Sendmail daemon to re-read the aliases file.
# sendmail -bi

To add a mail relay server (smart host) to the Sendmail configuration file, edit the /etc/mail/sendmail.cf file, modify the DS line, and refresh the daemon:
# vi /etc/mail/sendmail.cf
DSsmtpgateway.xyz.com.au
# refresh -s sendmail

To log Sendmail activity, place the following entry in the /etc/syslog.conf file, create the log file, and refresh the syslog daemon:
# grep mail /etc/syslog.conf
mail.debug  /var/log/maillog rotate time 7d files 4 compress
# touch /var/log/maillog
# refresh –s syslogd

Sendmail Configuration in AIX

Daemon : sendmail

To start the daemon :

# startsrc -s sendmail -a "-bd -q30m"
where
bd - To start the sendmail as a SMTP mail relay router
q - Is the interval in which the sendmail daemon processes the saved messages

To start the daemon automatically after the system boot:

a. # vi /etc/rc.tcpip

b. Uncomment the below line
start /usr/lib/sendmail "$src_running" "-bd -q${qpi}"

To display the status of the daemon :

# lssrc -s sendmail
# ps -ef | grep sendmail

To stop the daemon :

# stopsrc -s sendmail
# kill -1 `cat /etc/sendmail.pid`

Configuration File:

/etc/sendmail.cf - Where the hostname, Relay server name,... are stored.

Alias File :

/etc/aliases - Where the group(alias) to member mapping is stored.


To Add the hostname in the sendmail configuration :

a. Vi /etc/sendmail.cf

b. Change "#DwYourHostName" to "Dw{hostname of local server}"

c. # refresh -s sendmail


To Add the mail (relay) server in the sendmail configuration :

a. Vi /etc/sendmail.cf

b. Change "#DSrelayhostname" to "DS{hostname of the Relay Server}"

c. # refresh -s sendmail


To send the mails,

# echo "Test Message" | sendmail -v raja@server1.domain.com

If you add any alias in /etc/aliases file, then do the following

# sendmail -bi

This will make the sendmail daemon to re-read the aliases file.

To display the list of messages in the mail queue :

# mailq (or) # sendmail -bp

Directory containing log files and temp files associated with messages in the mail queue :

/var/spool/mqueue

To delete the first 1000 messages in the root's mail queue :


# mail -u root , then enter "d 1-1000"