PPoossttffiixx SSmmaallll//HHoommee OOffffiiccee HHiinnttss aanndd TTiippss

-------------------------------------------------------------------------------

OOvveerrvviieeww

This document combines hints and tips for "small office/home office"
applications into one document so that they are easier to find. The text
describes the mail sending side only. If your machine does not receive mail
directly (i.e. it does not have its own Internet domain name and its own fixed
IP address), then you will need a solution such as "fetchmail", which is
outside the scope of the Postfix documentation.

  * Selected topics from the STANDARD_CONFIGURATION_README document:

      o Postfix on a stand-alone Internet host
      o Postfix on hosts without a real Internet hostname

    Selected topics from the SASL_README document:

      o Enabling SASL authentication in the Postfix SMTP client
      o Supporting multiple ISP accounts in the Postfix SMTP client

See the SASL_README and STANDARD_CONFIGURATION_README documents for further
information on these topics.

PPoossttffiixx oonn aa ssttaanndd--aalloonnee IInntteerrnneett hhoosstt

Postfix should work out of the box without change on a stand-alone machine that
has direct Internet access. At least, that is how Postfix installs when you
download the Postfix source code via http://www.postfix.org/.

You can use the command "ppoossttccoonnff --nn" to find out what settings are overruled
by your main.cf. Besides a few pathname settings, few parameters should be set
on a stand-alone box, beyond what is covered in the BASIC_CONFIGURATION_README
document:

    /etc/postfix/main.cf:
        # Optional: send mail as user@domainname instead of user@hostname.
        #myorigin = $mydomain

        # Optional: specify NAT/proxy external address.
        #proxy_interfaces = 1.2.3.4

        # Alternative 1: don't relay mail from other hosts.
        mynetworks_style = host
        relay_domains =

        # Alternative 2: relay mail from local clients only.
        # mynetworks = 192.168.1.0/28
        # relay_domains =

See also the section "Postfix on hosts without a real Internet hostname" if
this is applicable to your configuration.

PPoossttffiixx oonn hhoossttss wwiitthhoouutt aa rreeaall IInntteerrnneett hhoossttnnaammee

This section is for hosts that don't have their own Internet hostname.
Typically these are systems that get a dynamic IP address via DHCP or via
dialup. Postfix will let you send and receive mail just fine between accounts
on a machine with a fantasy name. However, you cannot use a fantasy hostname in
your email address when sending mail into the Internet, because no-one would be
able to reply to your mail. In fact, more and more sites refuse mail addresses
with non-existent domain names.

Note: the following information is Postfix version dependent. To find out what
Postfix version you have, execute the command "ppoossttccoonnff mmaaiill__vveerrssiioonn".

SSoolluuttiioonn 11:: PPoossttffiixx vveerrssiioonn 22..22 aanndd llaatteerr

Postfix 2.2 uses the generic(5) address mapping to replace local fantasy email
addresses by valid Internet addresses. This mapping happens ONLY when mail
leaves the machine; not when you send mail between users on the same machine.

The following example presents additional configuration. You need to combine
this with basic configuration information as discussed the first half of this
document.

    1 /etc/postfix/main.cf:
    2     smtp_generic_maps = hash:/etc/postfix/generic
    3
    4 /etc/postfix/generic:
    5     his@localdomain.local             hisaccount@hisisp.example
    6     her@localdomain.local             heraccount@herisp.example
    7     @localdomain.local                hisaccount+local@hisisp.example

When mail is sent to a remote host via SMTP:

  * Line 5 replaces his@localdomain.local by his ISP mail address,

  * Line 6 replaces her@localdomain.local by her ISP mail address, and

  * Line 7 replaces other local addresses by his ISP account, with an address
    extension of +local (this example assumes that the ISP supports "+" style
    address extensions).

Specify ddbbmm instead of hhaasshh if your system uses ddbbmm files instead of ddbb files.
To find out what lookup tables Postfix supports, use the command "ppoossttccoonnff --mm".

Execute the command "ppoossttmmaapp //eettcc//ppoossttffiixx//ggeenneerriicc" whenever you change the
generic table.

SSoolluuttiioonn 22:: PPoossttffiixx vveerrssiioonn 22..11 aanndd eeaarrlliieerr

The solution with older Postfix systems is to use valid Internet addresses
where possible, and to let Postfix map valid Internet addresses to local
fantasy addresses. With this, you can send mail to the Internet and to local
fantasy addresses, including mail to local fantasy addresses that don't have a
valid Internet address of their own.

The following example presents additional configuration. You need to combine
this with basic configuration information as discussed the first half of this
document.

     1 /etc/postfix/main.cf:
     2     myhostname = hostname.localdomain
     3     mydomain = localdomain
     4
     5     canonical_maps = hash:/etc/postfix/canonical
     6
     7     virtual_alias_maps = hash:/etc/postfix/virtual
     8
     9 /etc/postfix/canonical:
    10     your-login-name    your-account@your-isp.com
    11
    12 /etc/postfix/virtual:
    13     your-account@your-isp.com       your-login-name

Translation:

  * Lines 2-3: Substitute your fantasy hostname here. Do not use a domain name
    that is already in use by real organizations on the Internet. See RFC 2606
    for examples of domain names that are guaranteed not to be owned by anyone.

  * Lines 5, 9, 10: This provides the mapping from "your-login-
    name@hostname.localdomain" to "your-account@your-isp.com". This part is
    required.

  * Lines 7, 12, 13: Deliver mail for "your-account@your-isp.com" locally,
    instead of sending it to the ISP. This part is not required but is
    convenient.

Specify ddbbmm instead of hhaasshh if your system uses ddbbmm files instead of ddbb files.
To find out what lookup tables Postfix supports, use the command "ppoossttccoonnff --mm".

Execute the command "ppoossttmmaapp //eettcc//ppoossttffiixx//ccaannoonniiccaall" whenever you change the
canonical table.

Execute the command "ppoossttmmaapp //eettcc//ppoossttffiixx//vviirrttuuaall" whenever you change the
virtual table.

EEnnaabblliinngg SSAASSLL aauutthheennttiiccaattiioonn iinn tthhee PPoossttffiixx SSMMTTPP cclliieenntt

Turn on client-side SASL authentication, and specify a table with per-host or
per-destination username and password information. The Postfix SMTP client
first searches the table for an entry with the remote SMTP server hostname; if
no entry is found, then the Postfix SMTP client searches the table for an entry
with the next-hop destination. Usually, that is the right-hand part of an email
address, but it can also be the information that is specified with the
relayhost parameter or with a transport(5) table.

    /etc/postfix/main.cf:
        smtp_sasl_auth_enable = yes
        smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
        smtp_sasl_type = cyrus
        relayhost = [mail.myisp.net]
        # Alternative form:
        # relayhost = [mail.myisp.net]:submission

    /etc/postfix/sasl_passwd:
        [mail.myisp.net]            username:password
        [mail.myisp.net]:submission username:password

Notes:

  * The "submission" destination port tells Postfix to send mail via TCP
    network port 587, which is normally reserved for email clients. The default
    is to send mail to the "smtp" destination port (TCP port 25), which is used
    for receiving mail across the internet. If you use an explicit destination
    port in main.cf, then you must use the same form also in the
    smtp_sasl_password_maps file.

  * Postfix does not deliver mail via TCP port 465 (the obsolete "wrappermode"
    protocol). See TLS_README for a solution that uses the "stunnel" command.

  * The "[" and "]" prevent Postfix from looking up the MX (mail exchanger)
    records for the enclosed name. If you use this form in main.cf, then you
    must use the same form also in the smtp_sasl_password_maps file.

  * The Postfix SMTP client opens the SASL client password file before entering
    the optional chroot jail, so you can keep the file in /etc/postfix and set
    permissions read / write only for root to keep the username:password
    combinations away from other system users.

  * Specify ddbbmm instead of hhaasshh if your system uses ddbbmm files instead of ddbb
    files. To find out what lookup tables Postfix supports, use the command
    "ppoossttccoonnff --mm".

  * Execute the command "ppoossttmmaapp //eettcc//ppoossttffiixx//ssaassll__ppaasssswwdd" whenever you change
    the sasl_passwd table.

Workarounds:

  * Some remote SMTP servers support PLAIN or LOGIN authentication only. By
    default, the Postfix SMTP client does not use authentication methods that
    send plaintext passwords, and defers delivery with the following error
    message: "Authentication failed: cannot SASL authenticate to server". To
    enable plaintext authentication specify, for example:

        /etc/postfix/main.cf:
            smtp_sasl_security_options = noanonymous

  * Some remote SMTP servers announce authentication mechanisms that don't
    actually work. It is possible via the smtp_sasl_mechanism_filter parameter
    to restrict the list of server mechanisms that the Postfix SMTP client will
    take into consideration:

        /etc/postfix/main.cf:
            smtp_sasl_mechanism_filter = !gssapi, !external, static:all

    In the above example, the Postfix SMTP client will decline to use
    mechanisms that require special infrastructure such as Kerberos or TLS.

  * The Postfix SMTP client is backwards compatible with SMTP servers that use
    the non-standard "AUTH=method..." syntax in response to the EHLO command;
    there is no Postfix client configuration needed to work around it.

SSuuppppoorrttiinngg mmuullttiippllee IISSPP aaccccoouunnttss iinn tthhee PPoossttffiixx SSMMTTPP cclliieenntt

Postfix version 2.3 supports multiple ISP accounts. This can be useful when one
person uses the same machine for work and for personal use, or when people with
different ISP accounts share the same Postfix server. To make this possible,
Postfix 2.3 supports per-sender SASL passwords and per-sender relay hosts. In
the example below, Postfix will search the SASL password file by sender before
it searches that same file by destination. Likewise, Postfix will search the
per-sender relayhost file, and use the default relayhost only as a final
resort.

    /etc/postfix/main.cf:
        smtp_sender_dependent_authentication = yes
        sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
        smtp_sasl_auth_enable = yes
        smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
        relayhost = [mail.myisp.net]
        # Alternative form:
        # relayhost = [mail.myisp.net]:submission

    /etc/postfix/sasl_passwd:
        # Per-sender authentication; see also /etc/postfix/sender_relay.
        user1@example.com           username2:password2
        user2@example.net           username2:password2
        # Login information for the default relayhost.
        [mail.myisp.net]            username:password
        [mail.myisp.net]:submission username:password

    /etc/postfix/sender_relay:
        # Per-sender provider; see also /etc/postfix/sasl_passwd.
        user1@example.com           [mail.example.com]:submission
        user2@example.net           [mail.example.net]

Notes:

  * If you are creative, then you can try to combine the two tables into one
    single MySQL database, and configure different Postfix queries to extract
    the appropriate information.

  * Specify ddbbmm instead of hhaasshh if your system uses ddbbmm files instead of ddbb
    files. To find out what lookup tables Postfix supports, use the command
    "ppoossttccoonnff --mm".

  * Execute the command "ppoossttmmaapp //eettcc//ppoossttffiixx//ssaassll__ppaasssswwdd" whenever you change
    the sasl_passwd table.

  * Execute the command "ppoossttmmaapp //eettcc//ppoossttffiixx//sseennddeerr__rreellaayy" whenever you change
    the sender_relay table.

