Mail Server

1
Mail Server
E-Mail Basics
Linux provides e-mail servers,
which communicate with enduser systems and with other email servers to manage your email needs.
2
Mail Server
1] User agent
for reading and sending mail
2] Transport agent
for forwarding mail between
machines.
3] Delivery agent
for delivering mail to the user mail
3
Mail Server
The user agent act as the user
front end.
It consists of the application
layer programs like mail.
It hands over mail to the
transport agent.
4
Mail Server
The transport agent is also
responsible for accepting mail
at the receivers end.

5
Mail Server
The delivery agent receives
mail from the transport agent
and deliver it to the actual
user’s address.

6
Mail Server

SMTP(Simple Mail Transfer Protocol)
Several protocols exist to manage
e-mail.
The most common of these is the
(SMTP), which is designed as a
push mail protocol, meaning that
the sending system initiates the
transfer.
7
Mail Server

SMTP(Simple Mail Transfer Protocol)
SMTP is used through most of a mail delivery
system.

The final stage, though, often employs a
pull mail protocol, such as the Post
Office Protocol (POP) or the Internet
Message Access Protocol (IMAP). With
these protocols, the receiving system
initiates the transfer.
8
Mail Server

SMTP(Simple Mail Transfer Protocol)
SMTP was designed to enable a
message to be relayed through an
arbitrary number of computers.
For instance, an end user might
compose a message, which is sent to
the local SMTP server.
9
Mail Server

POP (Post Office Protocol)
This system might use its own
internal routing table to redirect
the message to another local
system, from which the message
might be read, either directly or via
a POP or IMAP server.
10
Mail Server

POP (Post Office Protocol)
The POP and IMAP protocols can
be used by the local e-mail clients
to retrieve their e-mail from a
remote server.

11
Mail Server

POP (Post Office Protocol)
Currently, these are the two most
prevalent protocols for e-mail
retrieval.
These can be used to connect to
your local server, as well as Webbased mail servers such as Gmail.
12
Dovecot

Mail Server

Dovecot is an open source IMAP
and POP3 email server for
Linux/UNIX-like systems, written
with security primarily in mind.

13
Dovecot

Mail Server

Dovecot is an excellent choice for
both small and large installations.
It's fast, simple to set up, requires
no special administration and it
uses very little memory.

14
Dovecot

Mail Server

Most prominent (noticeable) features

1)Dovecot is among the highest
performing IMAP servers while still
supporting the standard mbox and
Maildir formats.

15
Dovecot

Mail Server

Most prominent (noticeable) features

2) Dovecot's indexes are selfoptimizing.
They contain exactly what the
user's client commonly needs,
no more and no less.
16
Dovecot

Mail Server

Most prominent (noticeable) features

3) Dovecot is self-healing.
It tries to fix most of the problems it
notices by itself, such as broken
index files.
The problems are however logged
so the administrator can later try to
figure out what caused them.
17
Mail Server

MIME(multipurpose internet mail extension)
Today the mail facility is wildly
used to deliver multimedia
attachments.
There attachments are separate
file containing binary characters
which use the 8 character of ASCII
code.
18
Mail Server

MIME(multipurpose internet mail extension)
There is a separate protocol which
handles these attachments MIMEmultipurpose internet mail
extension.
MIME extends the definition of mail
to include binary files and multiple
data format in single message.
19
Mail Server

MIME(multipurpose internet mail extension)
MIME encodes a message before
sending which is sub-sequently
decoded at the other side by
MIME.
MIME message can be easily
exchange between them.
20
Mail Server

Running Sendmail

Standard part of most Linux
distributions
One of the most popular mail
server programs on the Internet
Use Sendmail as an alternative to
expensive mail server programs
21

(Microsoft Exchange Server)
Mail Server

Running Sendmail

Standard part of most Linux
distributions
One of the most popular mail
server programs on the Internet
Use Sendmail as an alternative to
expensive mail server programs
22

(Microsoft Exchange Server)
Mail Server

Installing Sendmail

Quickly find out whether Sendmail
is installed on your system by
entering the following command
from a shell prompt:
$ rpm –q sendmail

23
Mail Server

Installing Sendmail

If Sendmail has been installed, the
package version is displayed. If not,
the message ‘package sendmail is
not installed’ is displayed.

24
Mail Server

Installing Sendmail

Check that m4 is installed by
running command
$ rpm –q m4
Check that sendmail –c4 is installed
by running the command
$ rpm –q sendmail –c4
25
Mail Server

Installing Sendmail

m4 and sendmail –c4 are required
if you want to make changes to
your Sendmail configuration.
They are should be there if
Sendmail is installed.
It never hurts to check.
26
Mail Server

Installing Sendmail

If Sendmail isn’t installed, instal by
following steps:
1)Insert the RedHat Linux
distribution CD in your CD drive.
2)When prompted to run the
Autorun file, click YES.
27

(The Package Manager window opens)
Mail Server

Installing Sendmail

3) Click Forward
4) Scroll down the list and select
Mail Server.
5) Click Forward.

28
Mail Server

Installing Sendmail

6) When Package Manager
program displays the list of
packages it processes to install,
Click Forward.
7) When the Package Manager
program is done, Click FINISH.
29
Mail Server

Installing Sendmail

To install Sendmail manually,
$ rpm –ivh
/mnt/cdrom/RedHat/RPMS/sentmail*

30
Mail Server

Modifying sendmail.mc
• Sendmail - one of the most difficult
program to configure that you will
ever encounter.
• In fact, the basic configuration file,
sendmail.cf is over 1000 lines long.
• You don’t want to mess with this file if
you can possibly avoid it.
31
Mail Server

Modifying sendmail.mc
• The sendmail.cf configuration file
is generated automatically from a
much shorter file called
senndmail.mc.
• This file contains special macros
that are processed by a program
called m4.
32
Mail Server

Modifying sendmail.mc
• The m4 program reads the macros in
the sendmail.mc file and expands
them to create the actual sendmail.cf
file.
• Even so, the sendmail.mc file is a
new hundred lines long.
33
Mail Server

Modifying sendmail.mc
You can find the sendmail.mc and
sendmail.cf files in the
/etc/mail directory.
Before you edit these files, you should
make backup copies of the current
files.
34
Mail Server

Modifying sendmail.mc
you can regenerate the
sendmail.cf file by commands:

$ cd /etc/mail
$ m4 sendmail.mc > sendmail.cf
$ server sendmail restart
35
Mail Server

Modifying sendmail.mc
First command changes the current
working directory to /etc/mail.
Second command compiles the
sendmil.mc command into the
sendmail.cf command.
Third command restarts the Sendmail
service so that the changes will take
effect.
36
Mail Server

Modifying sendmail.mc
Two strange conventions used in the
sendmail.mc file:
i) Comments don’t begin with at hash mark
(#), they begin with the letter dnl.
ii) Quotation marks must begin with a
backquote (`) and end with an apostrophe
(‘). So a properly quoted string looks like
this: MASQUERADE_AS(`mydomain.com’)
37
Mail Server

Modifying sendmail.mc
Two of the more common
configuration changes that you
may need to make sendmail.mc:

38
Mail Server

Modifying sendmail.mc
1) The default configuration allows
connections only from localhost.
If you want Sendmail to work as a server
for other computers on your network, look
for the following line in the sendmail.mc file:

DAEMON_OPTIONS(
`Port-smtp.Addr=127.0.0.1,
Name=MTA’)dnl
39
Mail Server

Modifying sendmail.mc
2) Masquerading/hidden/concealed
allows all the mail being sent from
your domain to appear as if it came
from the domain (for example,
wally@cleaver.net) rather than
from the individual host (i.e.
wally@wally.cleaver.net).
40
Mail Server

Modifying sendmail.mc
To enable masquerading, add lines
similar to these:
MASQUERADE_AS(`cleaver.net’)dnl
FEATURE (masquerade_envelope)dnl
FEATURE
(masquerade_entire_domain)dnl
MASQUERADE_DOMAIN(`cleaver.net’)dnl
41
Mail Server

Setting up aliases

An alias – also known as a virtual user
– is an incoming e-mail address that is
automatically routed to local users.
i.e. you may want to create a generic
account such as sales@mydomain.com
and have all mail sent to that account
delivered to a user named willie.
42
Mail Server

Setting up aliases

To do that, you edit the file
/etc/mail/virtursers/
This file starts out empty.
To create a virtual users, just like
the incoming e-mail address
followed by the actual recipient.
43
Mail Server

Setting up aliases

For example, here’s a virturusers file
that defines several aliases:
sales@mydomain.com
willie
bob@mydomain.com
robert
marketing@mydomain.com
robert
After you make changes, you should restart
the Sendmail service.
44
Mail Server

SPAM - Sendmail

• Spam artists – unscrupulous / dishonest /
corrupt marketers who clutter the Internet
with millions of unsolicited emails – are
constantly on the prowl for unprotected
Sendmail servers, which they can use to
launch their spam campaigns.

45
Mail Server

SPAM - Sendmail

• If you don’t protect your server, sooner or
later a spammer will coax your computer
into spending almost all its time sending out
the spammer’s e-mail.
• To protect your server from becoming an
indentured spam servant, you can configure
it to refuse any mail that merely wants to use
your computer to relay messages to other
computers.
46
47

Linux10 sendmail

  • 1.
  • 2.
    Mail Server E-Mail Basics Linuxprovides e-mail servers, which communicate with enduser systems and with other email servers to manage your email needs. 2
  • 3.
    Mail Server 1] Useragent for reading and sending mail 2] Transport agent for forwarding mail between machines. 3] Delivery agent for delivering mail to the user mail 3
  • 4.
    Mail Server The useragent act as the user front end. It consists of the application layer programs like mail. It hands over mail to the transport agent. 4
  • 5.
    Mail Server The transportagent is also responsible for accepting mail at the receivers end. 5
  • 6.
    Mail Server The deliveryagent receives mail from the transport agent and deliver it to the actual user’s address. 6
  • 7.
    Mail Server SMTP(Simple MailTransfer Protocol) Several protocols exist to manage e-mail. The most common of these is the (SMTP), which is designed as a push mail protocol, meaning that the sending system initiates the transfer. 7
  • 8.
    Mail Server SMTP(Simple MailTransfer Protocol) SMTP is used through most of a mail delivery system. The final stage, though, often employs a pull mail protocol, such as the Post Office Protocol (POP) or the Internet Message Access Protocol (IMAP). With these protocols, the receiving system initiates the transfer. 8
  • 9.
    Mail Server SMTP(Simple MailTransfer Protocol) SMTP was designed to enable a message to be relayed through an arbitrary number of computers. For instance, an end user might compose a message, which is sent to the local SMTP server. 9
  • 10.
    Mail Server POP (PostOffice Protocol) This system might use its own internal routing table to redirect the message to another local system, from which the message might be read, either directly or via a POP or IMAP server. 10
  • 11.
    Mail Server POP (PostOffice Protocol) The POP and IMAP protocols can be used by the local e-mail clients to retrieve their e-mail from a remote server. 11
  • 12.
    Mail Server POP (PostOffice Protocol) Currently, these are the two most prevalent protocols for e-mail retrieval. These can be used to connect to your local server, as well as Webbased mail servers such as Gmail. 12
  • 13.
    Dovecot Mail Server Dovecot isan open source IMAP and POP3 email server for Linux/UNIX-like systems, written with security primarily in mind. 13
  • 14.
    Dovecot Mail Server Dovecot isan excellent choice for both small and large installations. It's fast, simple to set up, requires no special administration and it uses very little memory. 14
  • 15.
    Dovecot Mail Server Most prominent(noticeable) features 1)Dovecot is among the highest performing IMAP servers while still supporting the standard mbox and Maildir formats. 15
  • 16.
    Dovecot Mail Server Most prominent(noticeable) features 2) Dovecot's indexes are selfoptimizing. They contain exactly what the user's client commonly needs, no more and no less. 16
  • 17.
    Dovecot Mail Server Most prominent(noticeable) features 3) Dovecot is self-healing. It tries to fix most of the problems it notices by itself, such as broken index files. The problems are however logged so the administrator can later try to figure out what caused them. 17
  • 18.
    Mail Server MIME(multipurpose internetmail extension) Today the mail facility is wildly used to deliver multimedia attachments. There attachments are separate file containing binary characters which use the 8 character of ASCII code. 18
  • 19.
    Mail Server MIME(multipurpose internetmail extension) There is a separate protocol which handles these attachments MIMEmultipurpose internet mail extension. MIME extends the definition of mail to include binary files and multiple data format in single message. 19
  • 20.
    Mail Server MIME(multipurpose internetmail extension) MIME encodes a message before sending which is sub-sequently decoded at the other side by MIME. MIME message can be easily exchange between them. 20
  • 21.
    Mail Server Running Sendmail Standardpart of most Linux distributions One of the most popular mail server programs on the Internet Use Sendmail as an alternative to expensive mail server programs 21 (Microsoft Exchange Server)
  • 22.
    Mail Server Running Sendmail Standardpart of most Linux distributions One of the most popular mail server programs on the Internet Use Sendmail as an alternative to expensive mail server programs 22 (Microsoft Exchange Server)
  • 23.
    Mail Server Installing Sendmail Quicklyfind out whether Sendmail is installed on your system by entering the following command from a shell prompt: $ rpm –q sendmail 23
  • 24.
    Mail Server Installing Sendmail IfSendmail has been installed, the package version is displayed. If not, the message ‘package sendmail is not installed’ is displayed. 24
  • 25.
    Mail Server Installing Sendmail Checkthat m4 is installed by running command $ rpm –q m4 Check that sendmail –c4 is installed by running the command $ rpm –q sendmail –c4 25
  • 26.
    Mail Server Installing Sendmail m4and sendmail –c4 are required if you want to make changes to your Sendmail configuration. They are should be there if Sendmail is installed. It never hurts to check. 26
  • 27.
    Mail Server Installing Sendmail IfSendmail isn’t installed, instal by following steps: 1)Insert the RedHat Linux distribution CD in your CD drive. 2)When prompted to run the Autorun file, click YES. 27 (The Package Manager window opens)
  • 28.
    Mail Server Installing Sendmail 3)Click Forward 4) Scroll down the list and select Mail Server. 5) Click Forward. 28
  • 29.
    Mail Server Installing Sendmail 6)When Package Manager program displays the list of packages it processes to install, Click Forward. 7) When the Package Manager program is done, Click FINISH. 29
  • 30.
    Mail Server Installing Sendmail Toinstall Sendmail manually, $ rpm –ivh /mnt/cdrom/RedHat/RPMS/sentmail* 30
  • 31.
    Mail Server Modifying sendmail.mc •Sendmail - one of the most difficult program to configure that you will ever encounter. • In fact, the basic configuration file, sendmail.cf is over 1000 lines long. • You don’t want to mess with this file if you can possibly avoid it. 31
  • 32.
    Mail Server Modifying sendmail.mc •The sendmail.cf configuration file is generated automatically from a much shorter file called senndmail.mc. • This file contains special macros that are processed by a program called m4. 32
  • 33.
    Mail Server Modifying sendmail.mc •The m4 program reads the macros in the sendmail.mc file and expands them to create the actual sendmail.cf file. • Even so, the sendmail.mc file is a new hundred lines long. 33
  • 34.
    Mail Server Modifying sendmail.mc Youcan find the sendmail.mc and sendmail.cf files in the /etc/mail directory. Before you edit these files, you should make backup copies of the current files. 34
  • 35.
    Mail Server Modifying sendmail.mc youcan regenerate the sendmail.cf file by commands: $ cd /etc/mail $ m4 sendmail.mc > sendmail.cf $ server sendmail restart 35
  • 36.
    Mail Server Modifying sendmail.mc Firstcommand changes the current working directory to /etc/mail. Second command compiles the sendmil.mc command into the sendmail.cf command. Third command restarts the Sendmail service so that the changes will take effect. 36
  • 37.
    Mail Server Modifying sendmail.mc Twostrange conventions used in the sendmail.mc file: i) Comments don’t begin with at hash mark (#), they begin with the letter dnl. ii) Quotation marks must begin with a backquote (`) and end with an apostrophe (‘). So a properly quoted string looks like this: MASQUERADE_AS(`mydomain.com’) 37
  • 38.
    Mail Server Modifying sendmail.mc Twoof the more common configuration changes that you may need to make sendmail.mc: 38
  • 39.
    Mail Server Modifying sendmail.mc 1)The default configuration allows connections only from localhost. If you want Sendmail to work as a server for other computers on your network, look for the following line in the sendmail.mc file: DAEMON_OPTIONS( `Port-smtp.Addr=127.0.0.1, Name=MTA’)dnl 39
  • 40.
    Mail Server Modifying sendmail.mc 2)Masquerading/hidden/concealed allows all the mail being sent from your domain to appear as if it came from the domain (for example, wally@cleaver.net) rather than from the individual host (i.e. wally@wally.cleaver.net). 40
  • 41.
    Mail Server Modifying sendmail.mc Toenable masquerading, add lines similar to these: MASQUERADE_AS(`cleaver.net’)dnl FEATURE (masquerade_envelope)dnl FEATURE (masquerade_entire_domain)dnl MASQUERADE_DOMAIN(`cleaver.net’)dnl 41
  • 42.
    Mail Server Setting upaliases An alias – also known as a virtual user – is an incoming e-mail address that is automatically routed to local users. i.e. you may want to create a generic account such as sales@mydomain.com and have all mail sent to that account delivered to a user named willie. 42
  • 43.
    Mail Server Setting upaliases To do that, you edit the file /etc/mail/virtursers/ This file starts out empty. To create a virtual users, just like the incoming e-mail address followed by the actual recipient. 43
  • 44.
    Mail Server Setting upaliases For example, here’s a virturusers file that defines several aliases: sales@mydomain.com willie bob@mydomain.com robert marketing@mydomain.com robert After you make changes, you should restart the Sendmail service. 44
  • 45.
    Mail Server SPAM -Sendmail • Spam artists – unscrupulous / dishonest / corrupt marketers who clutter the Internet with millions of unsolicited emails – are constantly on the prowl for unprotected Sendmail servers, which they can use to launch their spam campaigns. 45
  • 46.
    Mail Server SPAM -Sendmail • If you don’t protect your server, sooner or later a spammer will coax your computer into spending almost all its time sending out the spammer’s e-mail. • To protect your server from becoming an indentured spam servant, you can configure it to refuse any mail that merely wants to use your computer to relay messages to other computers. 46
  • 47.