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

  1. # vi /etc/mail/sendmail.mc
  2. Find the following directive(which it limits sendmail to the local computer) :
    DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
  3. Change it To:
    dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
  4. 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
  5. Iinsert 192.168.1(with out a dot at the end of the IP.)
    192.168.1      RELAY
  6. Back up /etc/mail/sendmail.cf
  7. Compile the the sendmail.mc program by using this command:
    # make -C /etc/mail
  8. Restart sendmail
    # service sendmail restart
  9. # 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.

  1. # mail root
  2. Type the message in the Subject field
  3. When you are done press CTRL-D
  4. Enter another address in the Cc field
  5. 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

# mail
& 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)

Spread the word

del.icio.us Digg Furl Reddit Help

Permalink • Print

Related Entries

Made with WordPress and a healthy dose of Semiologic • Sky Gold skin by Denis de Bernardy