Monday, November 8, 2010

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 



Tuesday, October 19, 2010

Mail Server Basics with Sendmail Configuration



Mail Server Basic Concept

* MTA - Mail Transfer Agent This is the piece of the mail system thats responsible for transfering the mails from one system to another e.g. Sendmail, POP, IMAP, Qmail, Postfix, Exim

· MUA - Mail User Agent These are just mail clients. Program that you use to compose and send mails Linux: mail, evolution, thunderbird, elm, mutt, pine Windows: Outlook Express, Microsoft Outlook, Eudora

· MDA - Mail Delivery Agent Sometimes it is referred to as LDA (Local Delivery Agent) MDA is not responsible for sending mails between systems. Its only responsible for moving the mails into user's mailbox. MTA receives the mail and hands over to MDA to deliver the mails into users mailbox e.g. Procmail

Lets see how email works

- show evolution configuration nouresh%linobox.om Auth Type: passwd Server Requires Authentication
- CRAM-MD5 --> check for supported types
- Username: abc%test.com
- shell> mail chan < notes.txt 

- shell> mail
- & 1
- & del 1
- & help
- & quit