20120106

Sendmail Configuration on Linux


Sendmail Configuration Guidence

In this section we will  focus on MTAs, I will show you the default implementation, and how to alter the default redhat enterprise implementation 
 
Below packages are required for sendmail configuration
 
You can check by typing below command:

# rpm -qa | grep sendmail 

  sendmail-8.13.1-2  

# rpm -qa | grep postfix 

  postfix-2.1.5-4.2.RHEL4 

# rpm -ql sendmail  

- /etc/mail  (Default Home Directory for Sendmail Configuration)

 - /etc/mail/access 
Can be used to deny access for relaying or receving messages  based on the content of the messages  

- /etc/mail/acesss.db
Sendmail queries the database version of the file such as berkeley DB 
Berkeley DB  should be installed to support sendmail to read the DB files.


# file /etc/mail/access*

# rpm -qa | grep -i db 

Package Version/Name: db4-4.2.  

 /etc/mail/helpfile 
 SMTP commands  
e.g. telnet localhost 25  

HELP   

- /etc/mail/local-host-names 
To know how to handle the domains which are considered to be local So it handles routing for   

- localhost  
- localhost.domain   
- FQDN, in my case
- postfix.mydomain.com  
- 192.168.10.30  
- 127.0.0.1  

Default MTA accepts messages for all the above

- /var/spool/mail/
Above directory contains mailbox per user
           e.g. /var/spool/mail/~username 

Traditional Unix Mbox  

Sendmail uses macrotize language called m4, As sendmail configuration is so  complex its abstracted to macro utility using m4  -

- /etc/mail/sendmail.mc

1. Just open the sendmail.mc file in VI editor

Search for “/127.0.0.1”

Note : ( If you are configuring as a localhost its applicable Other wise you need to change the IP address as per you need.)

2. Put “dnl” keyword front of the same line.
3. Save the file
4. Fire the below command to sunc the changes from sendmail.mc to sendmail.cf

#pwd
/etc/mail/

#m4 sendmail.mc > sendmail.cf

Restart the sendmail service :
/etc/init.d/sendmail restart

sendmail to user pia
#mail - "test mail" pia@mydomain.com
hi,

This test mail
.
CC:
You can check the mail log
#tail -f /var/log/maillog | grep "pia@mydomain.com"

You can make changes and configure in sendmail.mc Sendmail.mc is much easier to understand   

- /etc/mail/sendmail.cf   

     Sendmails main configuration file   


  dnl --> way of commenting  Sendmail is separated into two daemons:

# ps -ax | grep -i sendmail 

- Once accepts connection 
   e.g. sendmail: accepting connections on port 25 

- Other runs the queue 
   e.g.  sendmail: Queue runner@01:00:00 for 
         /var/spool/clientmqueue 
 01:00 --> 1 minute  

Mails get stored in /var/spool/clientmqueue,
queue runner daemon  wakes up every 1 minute 
/var/spool/clientmqueue own by smmsp  smmsp --> sendmail

mail submission program   
So users in our localsystem invokes the mail in local queue  /var/spool/clientmqueue, which gets scanned every 1 minute by   the queue runner  

- /etc/mail/trusted-users  
users that can send mail as others without a warning  Able to rewrite from section without sendmail complaining  

- /etc/mail/virtusertable

Allows us to setup virtual domains  e.g.  pia@postfix.mydomain.com 
pia (local account)  So we have given you a brief introduction to the default implementation of sendmail within Redhat framework 

Before we migrate to postfix, lets just generate a message and sendmail deliver the mail to the user pia   

# which mutt

Mutt is a great client and default it reads mbox format but also have the ability  to interact with Maildirs which is newer and more robust way of storing mail messages. However there is any environment variable set which mutt relies upon  

# set | grep -i mutt   MAIL=/var/spool/mail/root

This environment variable should point to proper users mail box As root you can read anyone's mailbox     

# which sendmail 

# ls -l /usr/sbin/sendmail 

# ls -l /etc/alternatives/mta 

SENDMAIL is monolithic. It handles all messaging binding to the MTA port  as well as local delivery 

# ps -ef | grep sendmail

You could see various instances (process) but all are tied with same binary   By default sendmail accepts mails from local user and deliver it to local and remote user 

No comments:

Post a Comment