SMTP, POP and IMAP

Mail service has three distinct components. The mail user agent (MUA) is what the user sees and interacts with, such as the Eudora, Outlook, Evolution, and Mutt programs. An MUA is responsible only for reading mail and allowing users to compose mail. The mail transport agent (MTA) handles the process of getting the mail from one site to another; Sendmail and Postfix are MTAs. Finally, the mail delivery agent (MDA) is what takes the message, once received at a site, and gets it to the appropriate user mailbox. Many mail systems integrate these components. For example, Microsoft Exchange Server integrates the MTA and MDA functionalities into a single system. (If you consider the Outlook Web Access interface to Exchange Server, it is also an MUA.) Lotus Domino also works in a similar fashion. Postfix, on the other hand, works as an MTA only, passing the task of performing local mail delivery to another external program. This allows each operating system or site configuration to use its own custom tool, if necessary (that is, to be able to use a special mailbox store mechanism).

In most straightforward configurations, sites prefer using the Procmail program to perform the actual mail delivery (MDA). This is because of its advanced filtering mechanism, as well as its secure design from the ground up. Many older configurations have stayed with their default /bin/mail program to perform mail delivery.

SMTP

SMTP means Simple Mail Transfer Protocol. It is used when email is delivered from an email client, such as Outlook Express, to an email server or when email is delivered from one email server to another. SMTP uses port 25. It is used by the Mail Transfer Agent (MTA) to deliver email to the recipient’s mail server. The SMTP protocol can only be used to send emails, not to receive them.

POP3

POP3 means Post Office Protocol. POP3 allows an email client to download an email from an email server. Its design assumes that the email client downloads all available email from the server and deletes them from the server. The advantage is that once messages are downloaded the internet connection can be removed and emails be read at leisure but user also downloads all messages whether needed or not. POP3 uses port 110 and provides a simple, standardized way for users to access mailboxes and download messages. User can leave copies of emails on the server.

IMAP

IMAP means Internet Message Access Protocol with similar features as of POP3 to download email from an email server by an email client but, has many more features than POP3. The IMAP protocol does not deletes the email on the server hence, requires more disk space and CPU resources than POP3. IMAP is a client/server protocol in which e-mail is received and held by server. IMAP requires small data transfer so can work over a slow connection. When requested to read a specific email message then, it will be downloaded from the server. IMAP uses port 143.

Postfix Server

The Postfix mail server is easy to cofigure and use. The Postfix executable is /usr/sbin/postfix. This daemon launches all related processes needed to handle mail delivery.

Postfix stores its configuration files in the /etc/postfix/ directory. The following is a list of the more commonly used files:

  • access — Used for access control, this file specifies which hosts are allowed to connect to Postfix.
  • cf — The global Postfix configuration file. The majority of configuration options are specified in this file.
  • cf — Specifies how Postfix interacts with various processes to accomplish mail delivery.
  • transport — Maps email addresses to relay hosts.

The aliases file can be found in the /etc/ directory. This file is shared between Postfix and Sendmail. It is a configurable list required by the mail protocol that describes user ID aliases.

Important parameters in the main.cf file are

  • myhostname – This parameter is used to set the name that Postfix will be receiving e-mail for. Typical examples of mail server hostnames are mail.example.com or smtp.example.org.
  • mydomain – This parameter is the mail domain that you will be servicing, such as example.com or
  • com.
  • myorigin – All e-mail sent from this e-mail server will look as though it came from this parameter. mydestination – This parameter lists the domains that the Postfix server will take as its final destination for incoming e-mail.
  • mail_spool_directory – You can run the Postfix server in two modes of delivery: directly to a user’s mailbox or to a central spool directory. The typical way is to store the mail in /var/spool/mail .
  • mynetworks – The mynetworks variable is an important configuration option. This lets you configure what servers can relay through your Postfix server.
  • smtpd_banner – This variable allows you to return a custom response when a client connects to your mail server. It is a good idea to change the banner to something that doesn’t give away what server you are using.
  • inet_protocol – This parameter is used to invoke the Internet Protocol Version 6 (IPv6) capabilities of the Postfix mail server. It is used to specify the Internet protocol version that Postfix will use when making or accepting connections. Its default value is ipv4.

On Fedora, RHEL, and Centos systems, by default, mail logs go to /var/log/maillog, as defined by the rsyslogd configuration file. If you need to change this, you can modify the rsyslogd configuration file, /etc/rsyslog.conf , by editing the following line:

mail.*           /var/log/maillog

Most sites run their mail logs this way, so if you are having problems, you can search through the /var/log/maillog file for any messages.Debian-based systems, like Ubuntu, store the mail-related logs in the /var/log/mail.log file. OpenSuSE and SuSE Linux Enterprise (SLE) store its mail-related logs in the files /var/log/mail , /var/log/mail.err , /var/log/mail.info, and /var/log/mail.warn .

Dovecot

Dovecot is used to allow users to access their email by either imap or pop protocols. The dovecot configuration file is located at /etc/dovecot.conf. The following lines should be added, edited or uncommented:

protocols = imap imaps pop3 pop3s

mail_location = maildir:~/Maildir

pop3_uidl_format = %08Xu%08Xv

# Required on x86_64 kernels

login_process_size = 64

Again, looking at each option:

  • protocols: specifies the protocols available to users to access their email. Dovecot supports imap(s) and pop3(s), and any or all may be used.
  • mail_location: specifies the format and location of each users mailbox. Here we see we are using maildir format and each user has their mailbox located at ~/Maildir. Examples for mbox format are provided in the configuration file.
  • pop3_uidl_format: is required to fix a problem with Outlook 2003 accessing mailboxes via pop3 so it makes sense to set this
  • login_process_size: The release notes for CentOS 5.1 state that “the Dovecot package on x86_64 kernels requires the parameter “login_process_size = 64″ to be added to /etc/dovecot.conf after an upgrade to CentOS 5.1”. 32-Bit installations are unaffected and do not require this setting.

If you have any issues connecting with either imap or pop3 to dovecot, check the IMAP specific settings and POP3 specific settings sections of the dovecot.conf configuration file for workarounds. The available options mostly affect older mail clients and workarounds for Microsoft Outlook and Outlook Express.

With CentOS 6 the configuration moved to /etc/dovecot/dovecot.conf. Dovecot can be started without any further changes to the configuration file and will automatically listen for connections on the ports for pop3(s) and imap(s). Changes to suite your environment will probably be required.

Create users mailboxes – Next we need to create a mailbox for each user in their home directory and set the appropriate permission, so using our example user john:

mkdir /home/john/Maildir

chown john:john /home/john/Maildir

chmod -R 700 /home/john/Maildir

If creating the user mailboxes as root then we must set ownership of the directory to the user.

Back to Tutorial

Apply for Linux Administration Certification Now!!

http://www.vskills.in/certification/Certified-Linux-Administrator

Get industry recognized certification – Contact us

Menu