Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
howtos:network_services:postfix_dovecot_mysql:postfix [2015/02/15 08:08 (UTC)]
astrogeek
howtos:network_services:postfix_dovecot_mysql:postfix [2018/10/08 02:14 (UTC)] (current)
astrogeek [Configuring The Postfix MTA]
Line 1: Line 1:
-===== Installing The Postfix MTA =====+====== Installing The Postfix MTA ======
  
-<note important>​This article ​is under construction ​and not complete! Please return later...</​note>​+This page is supplemental to main article: [[howtos:​network_services:​postfix_dovecot_mysql|Creating a Virtual Mail Server with Postfix, Dovecot ​and MySQL]]
  
-We will build and install ​Postfix ​using the build script from SBo. The steps shown here use versions current as of this writingbut you should use the version applicable to your Slackware version at the time you build it.+Postfix ​is a popular and secure mail transport agentor MTA.
  
-By default ​the SBo postfix ​script ​builds with dovecot for SASL, but without database support. You might want to check the SlackBuild script ​at the time you build for changes or other options.+We will build and install Postfix using the build script ​from [[http://​slackbuilds.org|SlackBuilds.org]] or SBo. The steps shown here use versions current as of this writing, but you should use the latest version applicable to your Slackware version ​at the time you build it.
  
-The essential steps to build postfix are...+By default the SBo postfix script builds with dovecot for SASL, which we need, but without the database support we also need. You might want to check the SlackBuild script at the time you build for changes or other options.
  
-===== Configuring The Postfix MTA ===== +We will assume that you are familiar with SlackBuilds and will provide only the essential steps for building postfix here. For more detailed information please visit the [[http://slackbuilds.org/howto/|SBo How-To page]].
-You should become ​familiar with the [[http://www.postfix.org/documentation.html|postfix documentation]] in order to properly configure and administer your mail server.+
  
-What follows is a minimum configuration to safely operate a virtual email server on the internet, but you will surely want to adapt it to you specific needs.+<​note>​If building for a Linode.com VPS you will either need to install the kernel-headers package, or preferably build on a local machine and then transfer the package to the VPS platform. You will also need to install the db48 package missing from the Linode.com Slackware.</​note>​ 
 + 
 +The essential steps for building postfix with the required database support are (as root): 
 +<​code>​ 
 +cd /tmp 
 +wget http://​slackbuilds.org/​slackbuilds/​14.1/​network/​postfix.tar.gz 
 +tar -xvzf postfix.tar.gz 
 +cd postfix 
 +cat postfix.info 
 +... 
 +DOWNLOAD="​http://​postfix.cs.utah.edu/​source/​official/​postfix-2.11.3.tar.gz"​ 
 +MD5SUM="​c3f0f51d8865559b40e9350eb3816011"​ 
 +... 
 + 
 +# Fetch archive from URL in DOWNLOAD line # 
 +wget http://​postfix.cs.utah.edu/​source/​official/​postfix-2.11.3.tar.gz 
 + 
 +# Verify integrity of archive - compare to MD5SUM line # 
 +md5sum postfix-2.11.3.tar.gz 
 +c3f0f51d8865559b40e9350eb3816011 
 + 
 +# Now build with database support # 
 +chmod +x postfix.SlackBuild 
 +DATABASE=mysql ./​postfix.SlackBuild 
 +</​code>​ 
 + 
 +The resulting package will be found in /​tmp/​postfix-2.11.3-x86_64-1_SBo.tgz (or simillar for 32 bit version). 
 + 
 +Copy the package file to the target platform if necessary and install: 
 +<​code>​installpkg {path-to/​}postfix-2.11.3-x86_64-1_SBo.tgz</​code>​ 
 +====== Configuring The Postfix MTA ====== 
 + 
 +You must become familiar with the [[http://​www.postfix.org/​documentation.html|postfix documentation]] in order to properly configure and administer your mail server. Additionally,​ a complete set of online documentation for your version is installed from the package to /​usr/​doc/​postfix-2.11.3/​html/,​ learn what is there. 
 + 
 +<note important>​You //must// become familiar with the tools available to you in order to safely admin and maintain your mail server! Take the time necessary to //read the man pages// - man postfix, man postconf, man master at minimum. And become familiar with the resources available through **man postfix:SEE ALSO** section, //before// you start your mail server! </​note>​ 
 + 
 +What follows is a minimum configuration to safely operate a virtual email server on the internet, but you will surely want to adapt it to your specific needs.
  
 Postfix has two main configuration files: Postfix has two main configuration files:
  
-* /​etc/​postfix/​master.cf +  ​* /​etc/​postfix/​master.cf 
-* /​etc/​postfix/​main.cf+  * /​etc/​postfix/​main.cf
  
 The master.cf file governs operation of the master daemon which listens for mail events and manages the many postfix utility processes. The master.cf file governs operation of the master daemon which listens for mail events and manages the many postfix utility processes.
Line 25: Line 60:
 vi /​etc/​postfix/​master.cf vi /​etc/​postfix/​master.cf
  
-//Uncomment the following lines...//+Uncomment the following lines #
 smtp      inet  n       ​- ​      ​n ​      ​- ​      ​- ​      smtpd smtp      inet  n       ​- ​      ​n ​      ​- ​      ​- ​      smtpd
 submission inet n       ​- ​      ​n ​      ​- ​      ​- ​      smtpd submission inet n       ​- ​      ​n ​      ​- ​      ​- ​      smtpd
Line 38: Line 73:
 vi /​etc/​postfix/​main.cf vi /​etc/​postfix/​main.cf
  
-//Now enter the following lines...//+# Enter the following lines #
  
 mynetworks_style = host mynetworks_style = host
 myorigin = $mydomain myorigin = $mydomain
  
-#Change my-domain.com to the actual domain name of your server+# Change my-domain.com to the actual domain name of your server ​#
 mydomain = my-domain.com mydomain = my-domain.com
  
-#​mydestination must be localhost only to allow postfix to deliver non-virtual system mail+# mydestination must be localhost only to allow postfix to deliver non-virtual system mail #
 mydestination = localhost mydestination = localhost
  
 #IMPORTANT - relay_domains should be empty to prevent your server from becoming a spam relay! #IMPORTANT - relay_domains should be empty to prevent your server from becoming a spam relay!
 #If you actually need to relay to other domains READ THE DOCUMENTATION CAREFULLY! #If you actually need to relay to other domains READ THE DOCUMENTATION CAREFULLY!
- relay_domains =+relay_domains =
  
 +# We have no local users, so no local notifications #
 biff = no biff = no
-append_dot_mydomain = no 
 </​code>​ </​code>​
  
 Now we need to configure the secure aspects of our mail server, again in main.cf: Now we need to configure the secure aspects of our mail server, again in main.cf:
- 
 <​code>​ <​code>​
 vi /​etc/​postfix/​main.cf vi /​etc/​postfix/​main.cf
  
-//Enter the following lines...//+Enter the following lines #
  
-#SSL certificates will be created at these locations when we configure dovecot+# SSL certificates will be created at these locations when we configure dovecot ​#
 smtpd_tls_cert_file = /​etc/​ssl/​localcerts/​dove.pem smtpd_tls_cert_file = /​etc/​ssl/​localcerts/​dove.pem
-smtpd_tls_key_file = /etc/ssl/localcerts/dove.key+smtpd_tls_key_file = /etc/ssl/private/dove.key
  
 #Accept only secure smtp connections #Accept only secure smtp connections
Line 87: Line 121:
 vi /​etc/​postfix/​main.cf vi /​etc/​postfix/​main.cf
  
-//Enter the following lines...//+Enter the following lines #
  
 #Tell postfix to use dovecot lmtp for virtual mail delivery #Tell postfix to use dovecot lmtp for virtual mail delivery
Line 97: Line 131:
 virtual_alias_maps = mysql:/​etc/​postfix/​mysql-virtual-alias-maps.cf virtual_alias_maps = mysql:/​etc/​postfix/​mysql-virtual-alias-maps.cf
  
-#Set localhost ​destinations+#Set localhost ​aliases path
 alias_maps = hash:/​etc/​aliases alias_maps = hash:/​etc/​aliases
 </​code>​ </​code>​
  
-The last four files do not yet exist on the system and so, must be created. The virtual ​files tell postfix how to interact with the mysql database. The final alias_maps file tells the postfix process where to send operational messages.+The last four files do not yet exist on the system and so, must be created. The files prefixed with "​virtual" ​tell postfix how to interact with the mysql database. The final alias_maps file tells the postfix process where to send operational messages.
  
 First we must tell postfix how to identify which virtual domains it handles mail for by providing a proper query of the virtual database. This query must return true if the domain is in the database: First we must tell postfix how to identify which virtual domains it handles mail for by providing a proper query of the virtual database. This query must return true if the domain is in the database:
Line 108: Line 142:
 vi /​etc/​postfix/​mysql-virtual-mailbox-domains.cf vi /​etc/​postfix/​mysql-virtual-mailbox-domains.cf
  
-//Enter the following lines...// +Enter the following lines #
 user= mailuser user= mailuser
 password = {your mailuser password} password = {your mailuser password}
-host = localhost+hosts = localhost
 dbname = mailserver dbname = mailserver
 query = SELECT 1 FROM virtual_domains WHERE name='​%s'​ query = SELECT 1 FROM virtual_domains WHERE name='​%s'​
Line 122: Line 155:
  
 This will return true (1) if the domain is found, NULL if not found, and an error message if the query or connection is not correctly configured. This will return true (1) if the domain is found, NULL if not found, and an error message if the query or connection is not correctly configured.
 +
 +Also note that other database connection options are available, for example if you are connecting to a remote database server, or multiple servers. See the mysql_table man page from the postfix package for complete connect parameter information.
  
 Next, we must tell postfix how to identify valid virtual mail box users. This query must also only return true if the mail box exists in the database. Next, we must tell postfix how to identify valid virtual mail box users. This query must also only return true if the mail box exists in the database.
Line 128: Line 163:
 vi /​etc/​postfix/​mysql-virtual-mailbox-maps.cf vi /​etc/​postfix/​mysql-virtual-mailbox-maps.cf
  
-//Enter the following lines...// +Enter the following lines #
 user= mailuser user= mailuser
 password = {your mailuser password} password = {your mailuser password}
-host = localhost+hosts = localhost
 dbname = mailserver dbname = mailserver
 query = SELECT 1 FROM virtual_users WHERE email='​%s'​ query = SELECT 1 FROM virtual_users WHERE email='​%s'​
Line 141: Line 175:
 <​code>​postmap -q me@my-domain.com mysql:/​etc/​postfix/​mysql-virtual-mailbox-maps.cf</​code>​ <​code>​postmap -q me@my-domain.com mysql:/​etc/​postfix/​mysql-virtual-mailbox-maps.cf</​code>​
  
-Next, we must tell postfix how to identify valid aliases in the database. This query too, must return ​true if the alias exists.+Next, we must tell postfix how to identify valid aliases in the database. This query must return ​the destination address for the alias.
  
 <​code>​ <​code>​
 vi /​etc/​postfix/​mysql-virtual-alias-maps.cf vi /​etc/​postfix/​mysql-virtual-alias-maps.cf
  
-//Enter the following lines...// +Enter the following lines #
 user= mailuser user= mailuser
 password = {your mailuser password} password = {your mailuser password}
-host = localhost+hosts = localhost
 dbname = mailserver dbname = mailserver
 query = SELECT destination FROM virtual_aliases WHERE source='​%s'​ query = SELECT destination FROM virtual_aliases WHERE source='​%s'​
Line 164: Line 197:
 vi /​etc/​aliases vi /​etc/​aliases
  
-//Enter the following lines...//+Enter the following lines #
 postmaster: root postmaster: root
-root: myself+root: root
 </​code>​ </​code>​
  
-After creating the aliases file, you must use the postmap ​utility to build the local aliases database...+After creating the aliases file, you must use the newaliases ​utility to build the local aliases database...
  
-<​code>​postmap /​etc/​aliases</​code>​+<​code>​newaliases</​code>​
  
 This will create the file /​etc/​aliases.db in format useable by postfix. This will create the file /​etc/​aliases.db in format useable by postfix.
Line 178: Line 211:
  
 [[howtos:​network_services:​postfix_dovecot_mysql|Return to main article page]] [[howtos:​network_services:​postfix_dovecot_mysql|Return to main article page]]
-{{tag>​howtos ​template}}+ 
 +====== Sources ====== 
 +  * Based primarily on [[http://​www.postfix.org/​documentation.html|Postfix documentation]] 
 +  * Originally written by [[wiki:​user:​astrogeek | astrogeek]] 
 +{{tag>​howtos ​postfix dovecot mysql}}

In Other Languages
QR Code
QR Code howtos:network_services:postfix_dovecot_mysql:postfix (generated for current page)