Wednesday, December 5, 2007

Configure sendmail to forward mails to the default mail server of the network domain

The following configuration settings are for making a sendmail server to forward the mails to the default mail server which actually does the job of sending the mails to the intented recipients.

1. Login as root and make a copy of sendmail.cf and sendmail.mc before proceeding.
cp /etc/mail/sendmail.cf /etc/mail/sendmail.old
cp /etc/mail/sendmail.mc /etc/mail/sendmail.mc.old

2. In sendmail.mc search for "define('SMART_HOST' " and change the line to
define('SMART_HOST', 'ip_address_of_network_server')

3. Next search for "dnl DAEMON_OPTIONS(" and change the line to
dnl DAEMON_OPTIONS('Port=smtp, Addr=127.0.0.1, Name='MTA')dnl

4. Next search for "MASQUERADE_AS" and change the line to
MASQUERADE_AS('mydomain.com')dnl

5. Run following commands:
make -C /etc/mail
yum -y install sendmail-cf
service sendmail restart

6. Test sendmail configuration by typing following command:
mail myemail@email.com The system will prompt for "Subject"
Subject: Hello
Next type the message
Hello World.
Then end the message with a "."(dot).
You should see the prompt now.
Wait for the mail to come in your inbox.
If you receive the mail that means the configuration has been done successfully.