Difference between revisions of "User:Paul/sandbox/Configure Postfix"
m (Paul moved page User:Paul/sandbox/Install and configure core mail server packages to User:Paul/sandbox/Configure Postfix without leaving a redirect) |
|||
Line 1: | Line 1: | ||
'''WARNING:''' This article is in a user sandbox, indicating it is a rough draft, and as such, is likely incomplete, contains buggy and insecure configurations, and is subject to substantial and frequent changes. | '''WARNING:''' This article is in a user sandbox, indicating it is a rough draft, and as such, is likely incomplete, contains buggy and insecure configurations, and is subject to substantial and frequent changes. | ||
+ | |||
+ | Postfix is configured as the last step in the mail server packages since their configuration largely dictates how Postfix is configured. The two main configuration files in Postfix are <code>main.cf</code> and <code>master.cf</code>, but there are also important supporting configuration files such as the files for mapping to support MySQL and filtering out unnecessary header data. | ||
+ | |||
+ | Nearly all of the commands in this article require <code>root</code> privileges: | ||
+ | |||
+ | username@servername:~$ sudo /bin/bash | ||
+ | |||
+ | == Configure Postfix support files == | ||
+ | |||
+ | === Mapping files to support MySQL configuration === | ||
+ | |||
+ | ==== mysql_virtual_alias_domainaliases_maps.cf ==== | ||
+ | |||
+ | root@servername:~# nano /etc/postfix/mysql_virtual_alias_domainaliases_maps.cf | ||
+ | |||
+ | Add: | ||
+ | user = mail | ||
+ | password = mailpassword | ||
+ | hosts = 127.0.0.1 | ||
+ | dbname = mail | ||
+ | query = SELECT goto FROM alias,alias_domain | ||
+ | WHERE alias_domain.alias_domain = '%d' | ||
+ | AND alias.address=concat('%u', '@', alias_domain.target_domain) | ||
+ | AND alias.active = 1 | ||
+ | |||
+ | ==== mysql_virtual_alias_maps.cf ==== | ||
+ | |||
+ | root@servername:~# nano /etc/postfix/mysql_virtual_alias_maps.cf | ||
+ | |||
+ | Add: | ||
+ | user = mail | ||
+ | password = mailpassword | ||
+ | hosts = 127.0.0.1 | ||
+ | dbname = mail | ||
+ | table = alias | ||
+ | select_field = goto | ||
+ | where_field = address | ||
+ | additional_conditions = and active = '1' | ||
+ | |||
+ | ==== mysql_virtual_domains_maps.cf ==== | ||
+ | |||
+ | root@servername:~# nano /etc/postfix/mysql_virtual_domains_maps.cf | ||
+ | |||
+ | Add: | ||
+ | user = mail | ||
+ | password = mailpassword | ||
+ | hosts = 127.0.0.1 | ||
+ | dbname = mail | ||
+ | table = domain | ||
+ | select_field = domain | ||
+ | where_field = domain | ||
+ | additional_conditions = and backupmx = '0' and active = '1' | ||
+ | |||
+ | ==== mysql_virtual_mailbox_domainaliases_maps.cf ==== | ||
+ | |||
+ | root@servername:~# nano /etc/postfix/mysql_virtual_mailbox_domainaliases_maps.cf | ||
+ | |||
+ | Add: | ||
+ | user = mail | ||
+ | password = mailpassword | ||
+ | hosts = 127.0.0.1 | ||
+ | dbname = mail | ||
+ | query = SELECT maildir FROM mailbox, alias_domain | ||
+ | WHERE alias_domain.alias_domain = '%d' | ||
+ | AND mailbox.username=concat('%u', '@', alias_domain.target_domain ) | ||
+ | AND mailbox.active = 1 | ||
+ | |||
+ | ==== mysql_virtual_mailbox_maps.cf ==== | ||
+ | |||
+ | root@servername:~# nano /etc/postfix/mysql_virtual_mailbox_maps.cf | ||
+ | |||
+ | Add: | ||
+ | user = mail | ||
+ | password = mailpassword | ||
+ | hosts = 127.0.0.1 | ||
+ | dbname = mail | ||
+ | table = mailbox | ||
+ | select_field = CONCAT(domain, '/', local_part) | ||
+ | where_field = username | ||
+ | additional_conditions = and active = '1' | ||
+ | |||
+ | === Privacy filter === | ||
+ | |||
+ | ==== header_checks ==== | ||
+ | |||
+ | root@servername:~# nano /etc/postfix/header_checks | ||
+ | |||
+ | Add: | ||
+ | /^Received:/ IGNORE | ||
+ | /^User-Agent:/ IGNORE | ||
+ | /^X-Mailer:/ IGNORE | ||
+ | /^X-Originating-IP:/ IGNORE | ||
+ | /^x-cr-[a-z]*:/ IGNORE | ||
+ | /^Thread-Index:/ IGNORE | ||
+ | |||
+ | == main.cf == | ||
+ | |||
+ | The <code>main.cf</code> file is the primary configuration file for Postfix, and it is enormous. Archive the original version, then create a new one: | ||
+ | |||
+ | root@servername:~# mv /etc/postfix/main.cf /etc/postfix/original.main.cf | ||
+ | root@servername:~# nano /etc/postfix/main.cf | ||
+ | |||
+ | A sample file that should work for the configuration laid out in this series or articles can be found in the [[User:Paul/sandbox/Sample_main.cf|sample main.cf]] article. It is very important to be familiar with the myriad directives in this file. A complete description of every directive can be found at [http://www.postfix.org/postconf.5.html Postfix.org]. | ||
+ | |||
+ | == master.cf == | ||
+ | |||
+ | Another important and huge configuration file is <code>master.cf</code>. Make an archive of the original version and make a new one: | ||
+ | |||
+ | root@servername:~# mv /etc/postfix/master.cf /etc/postfix/original.master.cf | ||
+ | root@servername:~# nano /etc/postfix/master.cf | ||
+ | |||
+ | A sample file that should work for the configuration laid out in this series or articles can be found in the [[User:Paul/sandbox/Sample_main.cf|sample master.cf]] article. It is very important to be familiar with the myriad directives in this file. Check out [http://www.postfix.org/master.5.html Postfix.org] for a description of <code>master.cf</code>. | ||
+ | |||
+ | root@servername:~# | ||
+ | root@servername:~# | ||
+ | root@servername:~# | ||
+ | |||
+ | == External links == | ||
+ | |||
+ | [http://www.postfix.org/ Postfix.org] | ||
+ | |||
+ | [http://www.postfix.org/postconf.5.html Postfix Configuration Parameters] | ||
+ | |||
+ | [http://www.postfix.org/master.5.html Postfix manual - master(5)] | ||
+ | |||
+ | [http://arstechnica.com/information-technology/2014/03/taking-e-mail-back-part-2-arming-your-server-with-postfix-dovecot/ Taking email back, part 2 | Ars Technica] | ||
+ | |||
+ | [[category:Mail server]][[category:Fully-functional mail server]] |
Revision as of 01:52, 22 May 2014
WARNING: This article is in a user sandbox, indicating it is a rough draft, and as such, is likely incomplete, contains buggy and insecure configurations, and is subject to substantial and frequent changes.
Postfix is configured as the last step in the mail server packages since their configuration largely dictates how Postfix is configured. The two main configuration files in Postfix are main.cf
and master.cf
, but there are also important supporting configuration files such as the files for mapping to support MySQL and filtering out unnecessary header data.
Nearly all of the commands in this article require root
privileges:
username@servername:~$ sudo /bin/bash
Configure Postfix support files
Mapping files to support MySQL configuration
mysql_virtual_alias_domainaliases_maps.cf
root@servername:~# nano /etc/postfix/mysql_virtual_alias_domainaliases_maps.cf
Add:
user = mail password = mailpassword hosts = 127.0.0.1 dbname = mail query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' AND alias.address=concat('%u', '@', alias_domain.target_domain) AND alias.active = 1
mysql_virtual_alias_maps.cf
root@servername:~# nano /etc/postfix/mysql_virtual_alias_maps.cf
Add:
user = mail password = mailpassword hosts = 127.0.0.1 dbname = mail table = alias select_field = goto where_field = address additional_conditions = and active = '1'
mysql_virtual_domains_maps.cf
root@servername:~# nano /etc/postfix/mysql_virtual_domains_maps.cf
Add:
user = mail password = mailpassword hosts = 127.0.0.1 dbname = mail table = domain select_field = domain where_field = domain additional_conditions = and backupmx = '0' and active = '1'
mysql_virtual_mailbox_domainaliases_maps.cf
root@servername:~# nano /etc/postfix/mysql_virtual_mailbox_domainaliases_maps.cf
Add:
user = mail password = mailpassword hosts = 127.0.0.1 dbname = mail query = SELECT maildir FROM mailbox, alias_domain WHERE alias_domain.alias_domain = '%d' AND mailbox.username=concat('%u', '@', alias_domain.target_domain ) AND mailbox.active = 1
mysql_virtual_mailbox_maps.cf
root@servername:~# nano /etc/postfix/mysql_virtual_mailbox_maps.cf
Add:
user = mail password = mailpassword hosts = 127.0.0.1 dbname = mail table = mailbox select_field = CONCAT(domain, '/', local_part) where_field = username additional_conditions = and active = '1'
Privacy filter
header_checks
root@servername:~# nano /etc/postfix/header_checks
Add:
/^Received:/ IGNORE /^User-Agent:/ IGNORE /^X-Mailer:/ IGNORE /^X-Originating-IP:/ IGNORE /^x-cr-[a-z]*:/ IGNORE /^Thread-Index:/ IGNORE
main.cf
The main.cf
file is the primary configuration file for Postfix, and it is enormous. Archive the original version, then create a new one:
root@servername:~# mv /etc/postfix/main.cf /etc/postfix/original.main.cf root@servername:~# nano /etc/postfix/main.cf
A sample file that should work for the configuration laid out in this series or articles can be found in the sample main.cf article. It is very important to be familiar with the myriad directives in this file. A complete description of every directive can be found at Postfix.org.
master.cf
Another important and huge configuration file is master.cf
. Make an archive of the original version and make a new one:
root@servername:~# mv /etc/postfix/master.cf /etc/postfix/original.master.cf root@servername:~# nano /etc/postfix/master.cf
A sample file that should work for the configuration laid out in this series or articles can be found in the sample master.cf article. It is very important to be familiar with the myriad directives in this file. Check out Postfix.org for a description of master.cf
.
root@servername:~# root@servername:~# root@servername:~#