Mails are the important part of our life, earlier we were used paper mails for informing important information to our relatives, business associates etc. it takes lot of time.Now days we using Email (electronic mails) which saves lot of time. They are lots free mailing services are available on internet, but if you are running a business, then a dedicated mail server will be required.
Tips: – Important Concepts
But before start configuring Linux mail Servers lets discuss about one another very important concept about the mailing Servers. DNS records for mail Servers (MX).  MX is an acronym for Mail eXchange. It specifies the name and relative preference of mail servers for the zone. MX is a DNS record used to define the host(s) willing to accept mail for a given domain. I.e. an MX record indicates which computer is responsible for handling the mail for a particular domain. You can have multiple MX records for a single domain name, ranked in preference order.

Like if you are sending mails from yahoo.com to gmail.com domains, then it is important to resolve proper MX record for the gmail.com domain, so that yahoo.com SMTP Servers will able to know the Servers address which is willing or responsible to entertain these mails. So if recipient is abc@gmail.com, then mails directed to gmail.com MX records Servers. It is very easy to find out the MX records for domain.

# nslookup
> set type=mx
> gmail.com
Server: 192.168.1.1
Address: 192.168.1.1#53


Non-authoritative answer:
gmail.com mail exchanger = 30 alt3.gmail-smtp-in.l.google.com.
gmail.com mail exchanger = 40 alt4.gmail-smtp-in.l.google.com.
gmail.com mail exchanger = 5 gmail-smtp-in.l.google.com.
gmail.com mail exchanger = 10 alt1.gmail-smtp-in.l.google.com.
gmail.com mail exchanger = 20 alt2.gmail-smtp-in.l.google.com.


Authoritative answers can be found from:
gmail.com nameserver = ns2.google.com.
gmail.com nameserver = ns1.google.com.
gmail.com nameserver = ns3.google.com.
gmail.com nameserver = ns4.google.com.
gmail-smtp-in.l.google.com internet address = 74.125.53.27
alt1.gmail-smtp-in.l.google.com internet address = 209.85.225.27
alt2.gmail-smtp-in.l.google.com internet address = 74.125.159.27
alt3.gmail-smtp-in.l.google.com internet address = 74.125.91.27
alt4.gmail-smtp-in.l.google.com internet address = 209.85.227.27
ns1.google.com internet address = 216.239.32.10
ns2.google.com internet address = 216.239.34.10
ns3.google.com internet address = 216.239.36.10
ns4.google.com internet address = 216.239.38.10
In this output, we can easily find out that gmail.com have many MX records, with the help these records availability on the internet, any mails floating on internet gets its domain for @gmail.com. There is also some preference before the MX records. These preferences are something like Server having less number gets higher preference or privileges for getting mails then other members mail Servers of the same domains.
Means of saying is that you should configure your DNS Server like this or register your MX records through your ISP, so that it gets correctly resolve in your network. Like linuxphobia.com resolve its MX records correctly.
# nslookup
> set type=mx
> linuxphobia.com
Server:         192.168.1.11
Address:        192.168.1.11#53
linuxphobia.com mail exchanger = 5 srv3.linuxphobia.com.
linuxphobia.com mail exchanger = 10 srv12.linuxphobia.com.
For configuring DNS correctly Please refer the Configuration OF DNS.
This document Contains:-
1.      Configuration of Sendmail Server.
2.      Understanding of Sendmail Server & its concepts
3.      Sendmail Server Security.
4.      Two locations Sendmail Server, within same domain.
5.      Configuration of Antivirus (clamav) over Sendmail Servers.
6.      Authentication of Sendmail Server with Openldap Server.
7.      pop & imap Server with dovecot.
8.      SSL or TLS over the both SMTP & POP.
Configuration of Sendmail Server

 

This configuration based on Centos 5.2, so please don’t confuse with the packages name & version given in the documentation that can be change with the OS version you are using.
Here we need to install first sendmail server packages. If you have yum-server then install like.
# yum install sendmail* -y
After installation you will that your system have these packages install.
# rpm -qa | grep sendmail
sendmail-devel-8.13.8-2.el5
sendmail-8.13.8-2.el5
sendmail-doc-8.13.8-2.el5
sendmail-cf-8.13.8-2.el5
Various configuration files which were used to configure the sendmail Server are located in folder /etc/mail. In sendmail configuration two files plays very important rule, one is editable & readable for us & another file, which is complied format of the first file & used by the sendmail Server itself, means of saying is that we used to edit sendmail.mc & compile it to sendmail.cf file, which will used by sendmail Server.
The directives used in sendmail.mc are human readable, having good comment with all directives, so that we were easily able to understand them & change them as per requirement.
Every Linux Servers have some mailing system from the start of the Server for the local mailing. But usually this mail Server is only bind to the loopback ethernet card. Means mails were only listen on the 127.0.0.1 address, no mail can communicate inside to outside & vice versa.
We can check it through netstat command.
# netstat -ntpl | grep sendmail
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      4878/sendmail: acce
As we need to configure the Server that able to send or receive mails from outside, so here we start editing the sendmail.mc file for this objective. In sendmail.mc file there is directive
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)dnl
This directive is refer that sendmail Server only listen on 127.0.0.1 address, So here we make it ineffective like this :-
dnl # DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)dnl
 Now as I mention earlier changes made in sendmail.mc is reflect on the sendmail.cf file, to make it happen we have to compile the sendmail.mc like this.
# m4 sendmail.mc > sendmail.cf
here we also have to restart the services of sendmail:-
service sendmail restart
Shutting down sm-client:                                    [  OK  ]
Shutting down sendmail:                                    [  OK  ]
Starting sendmail:                                                [  OK  ]
Starting sm-client:                                                [  OK  ]
Now we can again check through netstat command & see the difference from above output.
# netstat -anpt | grep sendmail
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      9097/sendmail: acce
Now our sendmail server is able to communicate the external SMTP Servers. These SMTP Server can postfix, Microsoft Exchange Server, IBM lotus Domain etc.
There are various ways to check your Server like telnet is very common way to check any type of service on Server.
# telnet 192.168.1.110 25
Trying 192.168.1.110…
Connected to srv12.linuxphobia.com (192.168.1.110).
Escape character is ‘^]’.
220 srv12.linuxphobia.com ESMTP Sendmail 8.13.8/8.13.8; Thu, 24 Feb 2011 01:45:31 +0530
We can see here we were able to see sendmail version in telnet output, it is big security beach that external viewers will able to know about your SMTP Server. We should stop this by managing the Login message directive in sendmail.mc file.
dnl define(`confSMTP_LOGIN_MSG’, `$j Sendmail; $b‘)dnl
change this directive to your message or company name .like this :-
define(`confSMTP_LOGIN_MSG’, `linuxphobia.com —> Little help on Linux’)dnl
Logs are important part of any type of Server. Logs should be highly debugged format, so that what exactly Server doing will monitoring by the administrators. In sendmail.mc file there is directive that used to logs level. Sendmail logs are saved in file /var/log/maillog. Let us see the log level directive. This really helps you lot in case of troubleshooting the sendmail problems.
dnl define(`confLOG_LEVEL’, `9′)dnl
Change this directive, so the logs will display more details over the every task.
define(`confLOG_LEVEL’, `15′)dnl
Now we will try to demonstrate various configurations of sendmail in our network prepared in lab. Let us start with the understanding of the Lab network that we prepare. Here we have two Linux machine with sendmail Servers. Srv3.linuxphobia.com & srv12.linuxphobia.com.
We will act them two location SMTP Servers in which srv3.linuxphobia.com act as SMTP gateway Server. SMTP gateway Server is Servers which basically entertain local SMTP request for the outside world. Means of saying is that all the mails from inside to outside domain go through this SMTP Server.
sendmail
Srv3 Servers installed sendmail as well as DNS Services & should resolved for linuxphobia.com domain & gets resolved for both the mail Servers. So make DNS entries for MX records Like—
# nslookup
> set type=mx
> linuxphobia.com
Server:         192.168.1.11
Address:        192.168.1.11#53
linuxphobia.com mail exchanger = 5 srv3.linuxphobia.com.
linuxphobia.com mail exchanger = 10 srv12.linuxphobia.com.
Here we can see srv3 (5) have more preference than srv12 (10), so we start exploring the configuration of srv12 first for better understanding.
 As we describe some of the points above for sendmail configuration, so after deploying them on srv12 we try sending mails between the two users on srv12 like u1 sends mail to u2, here they trying sending mails as user-name@linuxphobia.com like u1@linuxphobia.com & u2@linuxphobia.com.
Guess what happen…? Any idea…
Because srv3 have more preference than srv12, when u1@linuxphobia.com sending mails to u2@linuxphobia.com. Mails come out of srv12 Server & trying hitting on srv3 for the same user u2@linuxphobia.com. But as we know u2 is local user of srv12, so unknown User error comes in log file /var/log/maillog.

User u1 sends mail to u2@linuxphobia.com
# mail -v u2@linuxphobia.com
Subject: test
4:17 AM
Cc: u2@linuxphobia.com… Connecting to [127.0.0.1] via relay…
220 linuxphobia.com ESMTP —> Little help on Linux
>>> EHLO srv12.linuxphobia.com
250-srv12.linuxphobia.com Hello localhost.localdomain [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
>>> MAIL From: SIZE=46
250 2.1.0 … Sender ok
>>> RCPT To:
>>> DATA
250 2.1.5 … Recipient ok
354 Enter mail, end with “.” on a line by itself
>>> .
250 2.0.0 p1QMmGPS007307 Message accepted for delivery
u2@linuxphobia.com… Sent (p1QMmGPS007307 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 srv12.linuxphobia.com closing connection

<><><><><><><><><><><><><><>

Logs in srv3
Feb 27 04:18:16 srv3 sendmail[10024]: NOQUEUE: connect from srv12.linuxphobia.com [192.168.1.110]
Feb 27 04:18:16 srv3 sendmail[10024]: AUTH: available mech=ANONYMOUS LOGIN PLAIN, allowed mech=EXTERNAL GSSAPI KERBEROS_V4 DIGEST-MD5 CRAM-MD5
Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: Milter (clmilter): init success to negotiate
Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: Milter: connect to filters
Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: milter=clmilter, action=connect, continue
Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: — 220 linuxphobia.com ESMTP —> Little help on Linux
Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: <– EHLO srv12.linuxphobia.com Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: — 250-srv3.linuxphobia.com Hello srv12.linuxphobia.com [192.168.1.110], pleased to meet you Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: — 250-ENHANCEDSTATUSCODES Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: — 250-PIPELINING Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: — 250-8BITMIME Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: — 250-SIZE 10485760 Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: — 250-DSN Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: — 250-ETRN Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: — 250-DELIVERBY Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: — 250 HELP Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: <– MAIL From: SIZE=546
Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: Milter: senders:
Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: milter=clmilter, action=mail, continue
Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: — 250 2.1.0 … Sender ok
Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: <– RCPT To:
Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: Milter: rcpts:
Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: milter=clmilter, action=rcpt, continue
Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: — 550 5.1.1 … User unknown
Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: … User unknown
Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: <– DATA Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: — 503 5.0.0 Need RCPT (recipient) Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: <– RSET Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: — 250 2.0.0 Reset state Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: Milter (clmilter): abort filter Feb 27 04:18:16 srv3 sendmail[10024]: p1QMmGju010024: from=, size=546, class=0, nrcpts=0, proto=ESMTP, daemon=MTA, relay=srv12.linuxphobia.com [192.168.1.110]
Feb 27 04:18:17 srv3 sendmail[10024]: p1QMmGjv010024: <– QUIT Feb 27 04:18:17 srv3 sendmail[10024]: p1QMmGjv010024: — 221 2.0.0 srv3.linuxphobia.com closing connection
Logs in srv12
Feb 27 04:18:16 srv12 sendmail[7306]: p1QMmGwf007306: from=u1, size=46, class=0, nrcpts=1, msgid=<201102262248.p1QMmGwf007306@srv12.linuxphobia.com>, relay=u1@localhost
Feb 27 04:18:16 srv12 sendmail[7307]: NOQUEUE: connect from localhost.localdomain [127.0.0.1]
Feb 27 04:18:16 srv12 sendmail[7307]: AUTH: available mech=ANONYMOUS LOGIN PLAIN, allowed mech=EXTERNAL GSSAPI KERBEROS_V4 DIGEST-MD5 CRAM-MD5
Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: Milter: no active filter
Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: — 220 linuxphobia.com ESMTP —> Little help on Linux
Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: <– EHLO srv12.linuxphobia.com Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: — 250-srv12.linuxphobia.com Hello localhost.localdomain [127.0.0.1], pleased to meet you Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: — 250-ENHANCEDSTATUSCODES Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: — 250-PIPELINING Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: — 250-8BITMIME Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: — 250-SIZE Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: — 250-DSN Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: — 250-ETRN Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: — 250-DELIVERBY Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: — 250 HELP Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: <– MAIL From: SIZE=46
Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: — 250 2.1.0 … Sender ok
Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: <– RCPT To:
Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: — 250 2.1.5 … Recipient ok
Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: <– DATA Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: — 354 Enter mail, end with “.” on a line by itself Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: from=, size=333, class=0, nrcpts=1, msgid=<201102262248.p1QMmGwf007306@srv12.linuxphobia.com>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPS007307: — 250 2.0.0 p1QMmGPS007307 Message accepted for delivery
Feb 27 04:18:16 srv12 sendmail[7306]: p1QMmGwf007306: to=u2@linuxphobia.com, ctladdr=u1 (501/501), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30046, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p1QMmGPS007307 Message accepted for delivery)
Feb 27 04:18:16 srv12 sendmail[7309]: p1QMmGPS007307: SMTP outgoing connect on srv12.linuxphobia.com
Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPT007307: <– QUIT Feb 27 04:18:16 srv12 sendmail[7307]: p1QMmGPT007307: — 221 2.0.0 srv12.linuxphobia.com closing connection Feb 27 04:18:16 srv12 sendmail[7309]: p1QMmGPS007307: to=, ctladdr= (501/501), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120333, relay=srv3.linuxphobia.com. [192.168.1.11], dsn=5.1.1, stat=User unknown
Feb 27 04:18:16 srv12 sendmail[7309]: p1QMmGPS007307: p1QMmGPS007309: DSN: User unknown
Feb 27 04:18:16 srv12 sendmail[7309]: p1QMmGPS007309: to=, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31570, dsn=2.0.0, stat=Sent
Feb 27 04:18:16 srv12 sendmail[7309]: p1QMmGPS007309: done; delay=00:00:00, ntries=1
Feb 27 04:18:16 srv12 sendmail[7309]: p1QMmGPS007307: done; delay=00:00:00, ntries=1
In these logs we can see that as the mails rejected from both the servers (srv3 & srv12) with the error User unknown.
Why this happened..? There is two concepts behind this first mail Servers needs to know about the domain that is linuxphobia.com, here in our case it is getting the host for linuxphobia.com as after find the host for this domain mails will delivered to their MX records which is here srv3 & srv12, but now comes the second concept which is sendmail internally needs to know for which domain it’s responsible to handling the mails.
Like u1 is present on srv12, but srv12 will entertain those mails which have rcpt @linuxphobia.com only after getting entry in file named “local-host-names”.
# local-host-names – include all aliases for your machine here.
linuxphobia.com
 But there is one more consequence here that second concept override the first in local network.
Means like we add gmail.com in “local-host-names” & our lab server srv12 that able to resolve the gmail.com, even then only mails for user present on srv12 delivered like mails for u2@gmail.com will delivered to u2 local user & other mails gets error message user Unknown. But as we remove the entry of gmail.com from the local-host-names its gets delivered to Gmail Servers & the messages like
   —– The following addresses had permanent fatal errors —–
<u2@gmail.com>
    (reason: 550-5.1.1 The email account that you tried to reach does not exist. Please try)
   —– Transcript of session follows —–
… while talking to gmail-smtp-in.l.google.com.:
>>> RCPT To:<u2@gmail.com>
<<< 550-5.1.1 The email account that you tried to reach does not exist. Please try
<<< 550-5.1.1 double-checking the recipient’s email address for typos or
<<< 550-5.1.1 unnecessary spaces. Learn more at
<<< 550 5.1.1 http://mail.google.com/support/bin/answer.py?answer=6596 x1si7620764anx.90
550 5.1.1 <u2@gmail.com>… User unknown
I think here you understand few hidden concepts over sendmail & local-host-names. Let’s do some others too.
Let see in what format u2 gets mail from u1, when u1 send it from server consol to u2@linuxphobia.com.
From u1@srv12.linuxphobia.com  Mon Feb 28 17:28:21 2011
Date: Mon, 28 Feb 2011 17:28:20 +0530
From: u1@srv12.linuxphobia.com
To: u2@linuxphobia.com
Subject: test
test 5:50 PM
In this mail sender u1@srv12.linuxphobia.com, don’t you think it should like u1@linuxphobia.com. To make it correct we have to deploy the masquerade in sendmail.mc file.
MASQUERADE_AS(`linuxphobia.com’)dnl     à put your domain name here
FEATURE(masquerade_envelope)dnl             à just make uncomment
FEATURE(masquerade_entire_domain)dnl   àJust make uncomment
Rebuild the sendmail.cf file & restart the sendmail service. With this except root user every user which sends mails will represents the sender like user@domain_name, as in our case u1@linuxphobia.com.
From u1@linuxphobia.com  Wed Mar  2 01:38:42 2011
Date: Wed, 2 Mar 2011 01:38:42 +0530
From: u1@linuxphobia.com
To: u2@linuxphobia.com
Subject: test
test 11:14 Ampost_between]

Sendmail Server Tuning

The following limits the number of processes sendmail can fork to accept incoming messages or process its message queues to 20.) sendmail refuses to accept connections once it has reached its quota of child processes.

define(`confMAX_DAEMON_CHILDREN’, `20′)dnl
Limits the number of new connections per second. This caps the overhead incurred due to forking new sendmail processes. May be useful against DoS attacks or barrages of spam. (As mentioned below, a per-IP address limit would be useful but is not available as an option at this writing.)
define(`confCONNECTION_RATE_THROTTLE’, `3′)dnl
This limits the maximum numbers of recipients
define(`confMAX_RCPTS_PER_MESSAGE’,25)dnl
This limits the maximum length of all message headers in bytes
define(`confMAX_HEADERS_LENGTH’,16384)dnl
This particular line is to limit the mail size
Size is in bytes, so you have make it like for 10Mb, 10X1024X1024 = 10485760 bytes
define(`confMAX_MESSAGE_SIZE’, `10485760′)
This sets the time message can pass through server before being considered in a loop
define(`confMAX_HOP’, `15′)
Let we talk about the two location Servers, as srv12 have u1 & u2 users and srv3 have u3 & u4 users, now how mails flow from one mail server to another for domain users located on different servers.
Srv12.linuxphobia.com — u1 & u2 users
Srv3.linuxphobia.com —- u3 & u4 users
Even these users are located on local machine itself, but the called as domain users, means u1 will treated as u1@linuxphobia.com & same with others.
Please note these kinds of setup used where machine accounts are using for users setup & authentication. These things are much betters for clear the concepts of mail Servers. Usually in big organization administrators prefer to use centralize authentication like Openldap or Directory server, which we cover in later Chapters for mail Servers.
Here when users from srv3 trying to mail users for srv12 & vice versa, clash happen for users not present on the same machine, for this there should something on the mail Servers for these users also that make them resemble that remote uses also present on locally also.
 So now here we using one very important concept that widely used for mail Servers. This is called aliasing. In case of Linux there is file /etc/aliases, which already have many alias for various local accounts. For our solution we have to append such entries in srv3 & srv12‘s /etc/aliases file.
Srv3 /etc/aliases
u1:     u1@srv12.linuxphobia.com
srv12 /etc/aliases
u3:             u3@srv3.linuxphobia.com
u4:             u4@srv3.linuxphobia.com

After adding these lines you have to run newaliases command.

Antivirus Calmav configuration

Let us have something about antivirus on the sendmail server, here we were using calamav antivirus for the virus protection during mail transactions from one mail server to another.  Packages needed for the clamav installation.
clamav-db-0.96.5-1.el5.rf
clamav-milter-0.96.5-1.el5.rf
clamav-0.96.5-1.el5.rf
clamav-devel-0.96.5-1.el5.rf
After installing you will get two services for the clamav. You can also find them in /etc/init.d folder. We also need to update the clamav database on daily basis. freshclam command is used to update the database.
# freshclam
ClamAV update process started at Wed Mar 2 23:58:35 2011
WARNING: Your ClamAV installation is OUTDATED!
WARNING: Local version: 0.96.5 Recommended version: 0.97
DON’T PANIC! Read http://www.clamav.net/support/faq
main.cvd is up to date (version: 53, sigs: 846214, f-level: 53, builder: sven)
Downloading daily-12797.cdiff [100%]
[LibClamAV] ***********************************************************
[LibClamAV] *** This version of the ClamAV engine is outdated. ***
[LibClamAV] *** DON’T PANIC! Read http://www.clamav.net/support/faq ***
[LibClamAV] ***********************************************************
daily.cld updated (version: 12797, sigs: 61246, f-level: 60, builder: neo)
WARNING: Your ClamAV installation is OUTDATED!
WARNING: Current functionality level = 58, recommended = 60
DON’T PANIC! Read http://www.clamav.net/support/faq
bytecode.cvd is up to date (version: 140, sigs: 40, f-level: 58, builder: edwin)
Database updated (907500 signatures) from db.in.clamav.net (IP: 193.1.193.64)
Clamd successfully notified about the update.

Now we should start the clamav services.

# service clamd start
Starting Clam AntiVirus Daemon:                            [  OK  ]
 #service clamav-milter start
Starting Clamav Milter Daemon:                             [  OK  ]
Now it is time to make them available to Sendmail Server. So for this append these lines in sendmail.mc & make sendmail.cf file & restart the sendmail service.
INPUT_MAIL_FILTER(`clmilter’,`S=local:/var/clamav/clmilter.socket, F=, T=S:4m;R:4m’)dnl
define(`confINPUT_MAIL_FILTERS’, `clmilter’)

After this you can easily able to see in logs (/var/log/maillog) that all mails are scanned by the Antivirus clamav for Virus protection. Here we need to setup one cron for updating the clamav database daily.

Block extension file as mail attachment

For security some administrators prefer to block some kinds of extension files like .exe, .mp3, .bat etc. For this i prefer to use Procmail with Linux mailserver. Here in sendmail as well i am using Procmail to block these extension file as attachment.
Procmail needs to have procmailrc file in /etc folder for applying the setting on system wide, even the user based setting can be follow, for this we have to put .procmailrc file in user’s home folder.
Here i am providing the procmailrc file that i am using for system wide setting in /etc  folder to block the various extension files as attachment in mail. 

PATH=”/usr/bin:$PATH:/usr/local/bin”
SHELL=/bin/sh
LOGFILE=/var/log/procmail.log
LOGABSTRACT=ALL
VERBOSE=OFF

#This stops a bunch of bad attachements from coming through.Attachments are defined in the “filename” variable. You could #add or subtract file types using the same concept as below.

:0 HB
*^Content-Disposition.*filename=”.*.(vbs|wsf|eml|shs|exe|nws|chm|pif|vbe|hta|scr|reg|bat)”
/dev/null