Sunday, September 11, 2011

How to configure sendmail in AIX

This guide serve as a record on how i configured sendmail in AIX 7.1 to relay mails to my company's exchange.

Get sendmail running first

# lssrc -s sendmail
# ps -aef | grep sendmail
# startsrc -s sendmail -a "-bd -q30m"
# ps -aef | grep sendmail
You should see the following output
root  5704     1   0 11:08:42      -  0:00 sendmail: accepting connections on port 25
Ensure sendmail runs after a reboot. Edit the '/etc/rc.tcpip' file
# vi /etc/rc.tcpip
uncomment the following startup line in ‘/etc/rc.tcpip’
start /usr/lib/sendmail "$src_running" "-bd -q${qpi}"
Get sendmail to use local hosts for name resolution instead of DNS (default) Edit ‘/etc/netsvc.conf’ file
# vi /etc/netsvc.conf
Add the following:
hosts=local
For security purpose, change the permissions on the ‘/etc/netsvc.conf’ file to lock down root only access:
# chmod 600 /etc/netsvc.conf
Add into the ‘/etc/hosts’ file the IP address and hostname of the Exchange server. use telnet to verify network.
# telnet  25
Add the IP and hostname into ‘/etc/hosts’
# vi /etc/hosts
The email daemon requires FQDN, so say your host is "myserver", append "myserver." to your hostname in /etc/hosts. Backup the original ‘/etc/sendmail.cf’ file and edit.
# cp /etc/sendmail.cf /etc/sendmail.cf.
Make the following changes:
# vi /etc/sendmail.cf
For AIX 6.1, i changed the Dw as well. Don't need it in AIX 7.1. Change from:
#DwYourHostName
To:
Dw
Change from:
# "Smart" relay host (may be null)
# Relay host to forward outgoing mail not in the local domain to.
# To forward ALL mail to this relay host, uncomment the appropriate
# rule in ruleset 0, as indicated by the ruleset's comments.
#DSmailer:relayhostname
DS
To:
# "Smart" relay host (may be null)
# Relay host to forward outgoing mail not in the local domain to.
# To forward ALL mail to this relay host, uncomment the appropriate
# rule in ruleset 0, as indicated by the ruleset's comments.
#DSmailer:relayhostname
DS
Now refresh the ‘sendmail’ daemon with the new changes
# refresh –s sendmail
It will take a few minutes for the ‘ps’ process to return:
root  5704     1   0 11:08:42      -  0:00 sendmail: accepting connections on port 25
In the interim period the following will be displayed via ‘ps’:
root  5704     1   0 11:08:42      -  0:00 /usr/lib/sendmail –bd –q30
Test sendmail now.
# echo “test” |sendmail –v yourname@myinbox.com
Enable mail log by adding the following line in syslog.conf.
mail.debug     /var/log/maillog rotate files 6 time 30d compress
Now, create the log file and refresh syslogd.
# touch /var/log/maillog
# refresh -s syslogd

No comments: