Top

A Linux User Reference

Search tips
  • search ignores words that are less than 4 characters in length
  • searches are case insensitve
  • if a search does not return anything try it in Boolean mode then Query expansion mode by checking the appropriate radio button e.g. searching for 'cron' in just the Administration category returns nothing - presumably because the 50% threshold is reached. Boolean mode ignores this threshold so a search for 'cron' returns several hits
  • in Boolean mode preceding a word with a '+' means the result must include that word, a '-' means it must not
  • in Boolean mode '+crontab -anacron' means match articles about crontab that DO NOT mention anacron
  • to match a phrase e.g. 'manage system' check the Boolean mode radio button and enclose the phrase in quotes "some phrase ..."
  • in Query expansion mode the search context is expanded beyond the keywords you entered - relevancy of hits may well be degraded

MAIL

Mail Transfer Agents

  • Courier
    • The Courier mail transfer agent (MTA) is an integrated mail/groupware server based on open commodity protocols, such as ESMTP, IMAP, POP3, LDAP, SSL, and HTTP.

    • Courier provides ESMTP, IMAP, POP3, webmail and mailing list services within a single, consistent, framework. Individual components can be enabled or disabled at will. The Courier mail server now implements basic web-based calendaring and scheduling services integrated in the webmail module.

    Courier mta project documentation

  • Dovecot

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

    Dovecot project home page

  • Exim
    • Exim is a message transfer agent (MTA) developed at the University of Cambridge for use on Unix systems connected to the Internet.

    • It is freely available under the terms of the GNU General Public Licence.

    • In style it is similar to Smail 3, but its facilities are more general.

    • There is a great deal of flexibility in the way mail can be routed and there are extensive facilities for checking incoming mail.

    • All versions of Exim previous to version 4.x are now obsolete.

    • The current version is 4.82.

    Exim project home page

  • Postfix
    • Is Wietse Venema's mail server that started life at IBM research as an alternative to the widely-used Sendmail program.
    • Postfix attempts to be fast, easy to administer, and secure.
    • The outside has a definite Sendmail-ish flavor, but the inside is completely different.

    Postfix project home page

  • Qmail
    • qmail is a modern SMTP server which makes sendmail obsolete, written by Dan Bernstein.
    • qmail is a secure package.

    Qmail mirror selection site

    The above site " .. is a reference for qmail users. It's not designed to be easy to use -- it's designed to be comprehensive. There are things in here which have sharp edges! If you're looking for a tutorial site, visit Dave Sill's excellent Life With Qmail site."

  • Sendmail
    • Sendmail is a mail transfer agent (MTA) used for delivering mail across networks
    • every other mta claims to be a replacement for sendmail

    A source of documentation

    Although it is the oldest, may be on the way out, it still has a complete section in this site dedicated to it owing to

    • at the original time of writting, LPIC focused heavily on sendmail for MTA, mail topics - not so now
    • in terms of getting some understanding about Mail over networks, one MTA is as good as another (my view)
    • it's still going after all these years
    • most if not all the examples I use are based on sendmail
  • Unix mail life cycle

    Based on sendmail MTA

    (1) Email generated in client program

    (2) Client program invokes sendmail directly

    (3) Email placed in '/var/spool/clientmqueue'

    (4) Message relayed to MTA, moved from 'clientmqueue'

    (5) MTA stores message in '/var/spool/mqueue' while deciding on Local vs Remote delivery

    • Local mail - destination address is local

      • Mail should be delivered to a user's mailbox on the system.
      • Checks for match (fqdn, hostname, domainname) in /etc/mail/local-host-name
      • Checks for match of username (local part) in /etc/mail/aliases
    • Remote mail - no matches from local steps:

      • Conducts a DNS lookup (MX record) to determine mail server for destination domain. If no MX tries A record.
      • MTA makes a SMTP connection to IP of remote mail server and delivers mail.
      • If no MX or A record => error, message is discarded
    • Delayed Delivery - Server Down:

      • If Sendmail cannot reach next hop message is left in queue for (default) 5 days.
      • If next hop down for so long that message queue fills up Sendmail STOPS accepting new mail, external relays will send a temporary unavailable message to internal relays which will then queue
  • Internet ports and services
    /etc/services
    smtp      25/tcp    mail
    ssmtp    465/tcp    smtps              # SMTP over SSL
    pop3     110/tcp    pop-3              # POP version 3
    pop3     110/udp    pop-3
    imap2    143/tcp    imap               # Interim Mail Access P 2 and 4
    imap2    143/udp    imap
    imap3    220/tcp                       # Interactive Mail Access
    imap3    220/udp                       # Protocol v3
    imaps    993/tcp                       # IMAP over SSL
    imaps    993/udp
    pop3s    995/tcp                       # POP-3 over SSL
    pop3s    995/udp
    
  • Some terminology
    MUA

    Message User Agent. A program that displays messages for the user - an e-mail client. Uses an MTA to send and retrieve mail.

    MTA

    Mail Transfer Agent, receives and routes email via SMTP.

    MSP

    Message Submission Process, delivers mail to MTA for SMTP delivery. Sendmail is both.

    RelayServer

    Accepts mail that does not originate from that server and is not destined for a user on that server. All MTAs should be secured against unauthorised relaying.

    Smart Host

    A local mail server's MTA delivers all mail to a smart host for processing. A Smart host therefore acts as a central mail processing system for other systems - akin to a sorting office. See also configuring a Smart host - (Sendmail).

    Bastion Host

    A system that can be accessed from the internet, ideally, handles all incoming mail. If there are internal mail servers as well use a smart host(s), need to tell bastion host external MTA where to route incoming mail to.

  • Mail log entries
    /etc/syslog.conf

    Logging is MTA and configuration dependent e.g. use of /var/log/maillog, /var/log/mail.log, /var/log/sysylog, ...

    mail.*           @a-host.domain.com      # Send all mail log messages to this system
    mail.alert       @a-host.domain.com      # Just send mail alerts
    
  • Forwarding mail
    aliases
    • Aliases are used to forward mail to an address that differ from the received mail's 'To' address. This is done either via the /etc/aliases file or a user's ˜/.forward file.
    • Individual users can create their own mail aliases on an as-needed basis by stipulating an email address (on a line by itself) in their ~/.forward file.
    • A user's ~/.forward file is an alternative to the alias database. The file must be created by the user in their $HOME directory. If the file exists sendmail redirects mail for that user to the address(es) listed in this file. Addresses can specify programs.
    • System wide aliases can be set up via the /etc/aliases file.
    • The 'newaliases' command must be run after any changes to the /etc/aliases file.

    Sample entries - ˜.forward

    # Format:  
    # a comma-separated list of addresses
    
    mark@somewhere.else.com, root 
    
    #----------
    # Same as the single entry above
    mark@somewhere.else.com                    
    root
    

    Mail addressed to this user on this system will be redirected to root's mailbox and to mark@somewhere.else.com.

    Run a specified program

    root, "|/usr/bin/out-of-office mark"
    

    Mail addressed to this user on this system will be redirected to root's mailbox and to the out-of-office program.

    Stop forwarding mail

    $ rm ~/.forward
    
  • Aliases DB seed file
    /etc/aliases
    # Aliases in this file will NOT be expanded in the header from
    # Mail, but WILL be visible over networks or from /bin/mail.
    #
    # --NOTE--  The program "newaliases" must be run after this file is
    # updated for any changes to show through to sendmail.
    #
    # Basic system aliases -- these MUST be present.
    mailer-daemon:  postmaster
    postmaster:     root
    
    # General redirections for pseudo accounts.
    bin:            root
    daemon:         root
    .....
    www:            webmaster
    webmaster:      root
    .....
    
    # trap decode to catch security attacks
    decode:         root
    
    # Person who should get root's mail
    #root:          marc
    .....
    

    Initialise aliases DB after changes to /etc/aliases file

    # newaliases                 (Same as 'sendmail -bi' or 'sendmail -I')
    

    Restart or reload the MTA.

  • Test MTA connectivity
    telnet

    To make sure everything is working say, one can mimic a full mail session using 'telnet'.

    Assumption: Server is accessible on the sendmail SMTP TCP port 25

    Mimic a mail session

    $ telnet localhost 25
    trying 127.0.0.1...
    connected to localhost.
    escape character is '^]'.
    220 dnssvr ESMTP Exim 4.69 Mon, 20 Apr 2009 16:35:33 +0100
    helo another-web-site.org                                    (Command input)
    250 dnssvr Hello localhost [127.0.0.1]
    MAIL FROM:sender@another-web-site.org                        (Command input)
    250 OK
    RCPT TO: user@my-site.com                                    (Command input)
    250 Accepted
    DATA                                                         (Command input)
    354 Enter message, ending with "." on a line by itself
    hello there                                                  (Command input)
    .                                                            (Command input)
    250 OK id=1LvvYY-0002il-8s
    quit                                                         (Command input)
    221 dnssvr closing connection
    connection closed by foreign host.
    

    Check the mail queue for the 'telnet mail'

    # mailq
     0m  1.2K 1LvvYo-0002jB-2D <> *** frozen ***
              sender@another-web-site.org