Postfix server configuration

Postfix server (Debian / Ubuntu) is:

  • configured to primary domain faix.cz
  • listening on SMTP port 25 on home-server machine
  •  
    From Internet it delivers email for following domain: faix.cz
    From LAN it delivers email for following domain: home.lan

  • Every LAN computer forwards it’s mail for any user to home-server mail server and is processed to users following rules in /etc/postfix/recipient_canonical
  • Sender mapping follows the rules in /etc/postfix/canonical and /etc/postfix/sender_canonical configuration files (not in use now).
  • All mail is forwarded to users in following virtual table /etc/postfix/virtual
  • Any internal email domain is changed following rules in /etc/postfix/generic configuration file
  • Do not forget to use command postmap /etc/postfix/configuration_file every time you change file with ‘hash:‘ prefix
  • After any configuration change you have to reload Postfix service postfix reload
  •  
    Postfix installation

    apt-get install postfix
    postmap /etc/aliases
    postmap /etc/postfix/canonical
    postmap /etc/postfix/sender_canonical
    postmap /etc/postfix/generic
    postmap /etc/postfix/virtual

    /etc/mailname

    faix.cz
    

    /etc/postfix/main.cf

    alias_database = hash:/etc/aliases
    alias_maps = hash:/etc/aliases
    append_dot_mydomain = yes
    biff = no
    config_directory = /etc/postfix
    inet_interfaces = 192.168.122.1
    mailbox_command = /usr/bin/procmail
    mailbox_size_limit = 0
    mydomain = faix.cz
    myhostname = mail.$mydomain
    mynetworks = 127.0.0.0/8 192.168.122.0/27
    myorigin = /etc/mailname
    recipient_delimiter = +
    relayhost =
    smtpd_banner = $myhostname NO UCE ESMTP
    smtpd_delay_reject = no
    smtpd_helo_required = yes
    
    canonical_maps = hash:/etc/postfix/canonical
    sender_canonical_maps = hash:/etc/postfix/sender_canonical
    recipient_canonical_classes = envelope_recipient
    recipient_canonical_maps = regexp:/etc/postfix/recipient_canonical
    smtp_generic_maps = hash:/etc/postfix/generic
    local_header_rewrite_clients = static:all
    
    smtpd_recipient_restrictions =
    permit_sasl_authenticated
    permit_mynetworks
    reject_unknown_sender_domain
    reject_unauth_destination
    reject_rbl_client cbl.abuseat.org
    reject_rbl_client sbl-xbl.spamhaus.org
    reject_rbl_client bl.spamcop.net
    reject_rhsbl_sender dsn.rfc-ignorant.org
    
    unknown_address_tempfail_action = $reject_tempfail_action
    reject_tempfail_action = defer_if_permit
    
    strict_rfc821_envelopes = yes
    
    virtual_maps = hash:/etc/postfix/virtual
    mydestination = $myhostname, smtp.$mydomain, mail.$mydomain, home.lan, localhost, localhost.localdomain

    /etc/postfix/virtual

    faix.cz virtual domain
    postmaster@faix.cz faix@gmail.com
    admin@faix.cz faix@gmail.com
    root@faix.cz faix@gmail.com zada@gmail.com
    @faix.cz faix@gmail.com

    /etc/aliases

    postmaster: admin
    webmaster: admin
    www-data: admin
    abuse: admin
    nagios: root
    admin: faix@gmail.com
    root: faix@gmail.com

    /etc/postfix/recipient_canonical

    /^root(.*)home[.]lan$/ root@faix.cz
    /^root(.*)$/ root@faix.cz
    /^pytlicek(.*)$/ faix@gmail.com
    /^zada(.*)$/ zada@gmail.com

    /etc/postfix/generic

    @home.lan @faix.cz
    

    Print Friendly, PDF & Email