March 3, 2009
How to: Configure sendmail on CentOS 5
If you have not installed sendmail, then install it as follows:
# yum install sendmail
The sendmail directory is /etc/mail.
There are two configuration files:
- sendmail.cf
- submit.cf
sendmail.mc
This is the sendmail macro config file for m4. If you make changes to /etc/mail/sendmail.mc, you will need to regenerate the /etc/mail/sendmail.cf file by running the following command: installed and then performing a # make -C /etc/mail
local-host-names file allow you to include all aliases for your machine.
/etc/aliases file allow you to forward email from one user to another user.
To configure sendmail
# vi /etc/mail/sendmail.mc
- Find the following directive(which it limits sendmail to the local computer) :
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
- Change it To:
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
- Add net works IP addresses to /etc/mail/access, for example, to allow all computers on the 192.168.1.0 net work to send mail to your server, you would do the following:
# vi /etc/mail/access
- Iinsert 192.168.1(with out a dot at the end of the IP.)
192.168.1 RELAY
- Back up /etc/mail/sendmail.cf
- Compile the the sendmail.mc program by using this command:
# make -C /etc/mail
- Restart sendmail
# service sendmail restart
# chkconfig sendmail on
If you have installed and configured both sendmail and postfix, do not start them at the same time. Only one should be started.For example,
# service sendmail stop # service postfix start
To switch between the two electronic mails, use one of the following command:
# system-switch-mail # alternatives --config mta
To send mail to another user, use the mail command.
# mail root
- Type the message in the Subject field
- When you are done press CTRL-D
- Enter another address in the Cc field
- Press Enter to send the message
# mail root Subject: This is a test..... Cc: Null message body; hope that's ok
To read message 1
& 1
d command deletes the message
q command quit from the mail program
RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)

