Sendmail

Question :
Configure SMTP mail service according to the following requirements :
:- Your mail server should accept mail from remote hosts and localhost.
:- susan must be able to receive mail from remote hosts.
:- Mail delivered to susan spools in /var/spool/mail/susan.

Answer :
protocol ports
tcp 25

# rpm -q sendmail
# rpm -q sendmail-cf

=-> sendmail-cf file contains the macro for sendmail

# yum install -y sendmail-cf
# cd /etc/mail

The Main directory for sendmail is /etc/mail. The main configuration file sendmail.cf is very complex. “Very IMP” Don’t edit sendmail.cf,edit only sendmail.mc
The only line to change in sendmail.mc is line starting with DAEMON_OPTIONS.
Comment following line by dnl, dnl=delete till next line
Goto line num 108 using :108 or search for 127 using /127 in command mode of vi

# vim /etc/mail/sendmail.mc
dnl # DAEMON_OPTIONS(‘port=smtp,Addr=127.0.0.1, Name=MTA’)dnl
:wq

# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
# service sendmail status
# service sendmail restart
# chkconfig sendmail on

# netstat -ant

127.0.0.1:25 =-> Output before you run m4 command.
0.0.0.1:25 =-> Output after you run m4 command.

Cross check exercise for Mail

# mail -v susan@station33.example.com

or

# mail -s “Test Mail” susan@station33.example.com
hello
.
cc: acctmgr@station33.example.com,andrew@station33.example.com

—————–syntax
Test mailbox acess:

# mutt -f ://@

—————–

To Retrieve mail using mutt for susan

# mutt -f pop://susan@station33.example.com
yes
password (give password)
i to exit
q to quit

:- Mail delivered to susan spools in /var/spool/mail/susan.
Nothing to do. This is done by default by sendmail*

Troubleshooting
Sometimes it may happen that sendmail starts very slowly, in that case work around is to check your /etc/hosts file and add following entry :

127.0.0.1 localhost.localdomain localhost

In order to send mails from ubuntu command line (terminal):

# mail -s “Test MAil” raj@gla.com
Cc:
hello
+D

You would have to press +D simultaneously to send mail.

Possibly Related Posts: