Table of content
Installing a postfix server, whose communications will be encrypted to protect passwords and mail contents. User accounts will be managed from an LDAP directory. To limit the receipt of spam, several strategies can be implemented: blacklist, greylist, message analysis, …
- Requirement: OpenLDAP, MySQL
- Reference: Postfix
- Follow-up: SPF, DKIM, Grey-listing, SpamAssassin
Build information
Ensure the following options:
main.cf
Directories and files
Paths of directories and programs used by postfix
Information
Presentation of an identification banner when connecting.
Communication protocols
Communication with the server can be done either by IPv4 or IPv6. In addition, all network interfaces are allowed to receive mails.
To have a correct mail server behaviour, in particular due to the
fight against spam, do not forget to include in the DNS the
A
and AAAA
records as well as the corresponding
reverse (PTR
record).
Resources
The size of a message is limited to 15MB, this limit applies to both, messages sent by a user or to those passing through the server.
UNIX owner
Unix user accounts that own the different queues and Postfix
’s
processes.
If these settings are changed, it is necessary to execute the command:
1 |
|
Identity and home network
In the event the computer has multiple names, it is necessary to
clarify which one should be used (using myhostname
) to
represent the service.
Directive mynetworks_style
indicates machines that are allowed to
pass messages through the server (later validated by the rule
permit_mynetworks
), in the configuration shown the value host
limits transit to this server. It is also possible to indicate the
entire subnet where the server using subnet
, or to define
mynetworks
to get better granularity.
Addresses rewriting
-
If the mail is delivered locally with unspecified origin, origin will be added to form an address like
user
@
myorigin
-
If the address belongs to a sub domain in
masquerade_domains
then it will be rewritten to show only the domain listed. For example ifexample.com
is listed, then the addressfoo@devil.example.com
will be translated intofoo@example.com
. This allows for example to a mail gateway to hide the name of the machine sending the message and display only its domain name. Using an exclamation mark (!
) can establish an exception to this transformation.
Relaying, virtual domain, local delivery and transport
relay_domains
: domains for which we will act as an intermediary.virtual_mailbox_domains
: domains for which users have a mailbox but not a Unix account.virtual_alias_domains
: domains for which email addresses are to be rewritten to other addresses, local or not.mydestination
: list of hosts or addresses for which messages are to be delivered locally (a redirect is still possible using thealiases
file)transport
: explicitly specifies the transport to use to transfer/deliver the message (local
,virtual
,discard
,relay
,smtp
, …)
SASL authentication
SASL authentication use the $mydomain
realm (here
example.com
). Anonymous connection are not allowed. Other parts of
the configuration are also based on
smtpd.conf
file.
TLS encryption
Use of TLS is not required (by setting
smtpd_tls_security_level
to may
), this
allows to keep a better compatibility with all the clients and mail
servers, however they can still decide to authenticate the user (by
using the AUTH
command) and in this case encryption is required
(smtpd_tls_auth_only
set to yes
) so that the
password is protected.
Receiption and verification rules
Messages will be accepted on the following criteria:
- membership to an authorized network (
mynetworks_style
, …) - presence and matching of the DNS records of type
MX
,A
,AAAA
, andPTR
for the different names (server, domain, …) - authenticated user
- access list (defined in
access.cf
) - recipient for the mail, or relaying for an authorized domain
(
virtual_alias_domains
,virtual_mailbox_domains
,relay_domains
,transport_maps
, …) - spam detection policy: black listing, grey listing, SPF, …
smtpd.conf
The smtpd.conf
configuration file gets
its name from the smtpd_sasl_path
parameter defined in
main.cf
. It contains information about the
authentication mechanism to be used by SASL.
In this configuration file, spaces at the end of the line are not trimmed and are considered part of the parameter, you must be careful not to put them here.
The authentication mechanism is based on saslauthd
which
allows querying an LDAP directory without requiring to save the passwords
in clear text inside the directory. In counterpart, it is necessary to
transmit the passwords in clear text (plain
or login
)
between the client and server. Password protection depends on the use of an
encrypted connection.
access.cf
This file is used in the smtpd_sender_restrictions
definition
to see if the messages sent by that person (ie: e-mail) are accepted.
The action that is most often applied is REJECT
.
A table named access
is created in order to reject mail based
on sender, only the fields pattern
and action
will
be used by postfix
, the others being set up
for information.
1 2 3 4 5 6 7 |
|
- Connection information to the database:
- Table and fields used to define the actions to be performed
- (
REJECT
,DEFER
,DISCARD
, …)