Postfix How-to: Draft 1
Logging On
You must log into the system as root to edit the Postfix files. To use the Post fix commands, you must use “su - root” as your logon.
Configuration Files
Here are a list of the Postfix configuration files and a brief description (location: /etc/postfix/):
- main.cf , primary configuration file for Postfix
- mydomainname.com.virtual, defines email addresses for a domain
- mydomainname.com.virtual.db, database for reference
Commands
Here is a list of Postfix commands and a brief description:
- Postfix start, starts Postfix
- Postfix reload, reloads any changes to main.cf
- Postfix end, ends Postfix
- Postmap, generates indexed files.
- Postconf, used to make edits to main.cf
Note: Line continuation – Postfix recognizes the any line that starts with a white space character (tab or spaces) as being a continuation of the previous line.
Note: Multiple values – you can use commas or spaces to separate multiple values.
Adding to Existing Domains
This section reviews how to add an email address to an existing domain.
Editing the Virtual File
First, you will need to locate the virtual file for the domain. (If the file does not exist, then you will need to go to the section about how to set up Postfix for a new domain.) This file should be located in /etc/postfix/ and the naming convention will be mydomainname.com.virtual.
Once you have located the file, you will need to open it in the text editor of your choice. The file will look something like the following.
1 mydomainname.com virtual
2 address1@mydomainname.com user1
3 address2@mydomainname.com user2, address@hotmail.com
4 @mydomainname.com address@hotmail.com
The first line identifies which domain this virtual file belongs to. The left hand side is all that matters; the right hand side value does nothing. It is simple a standard to add the word virtual.
The second line is an example of an email address being redirected to a user on the machine. The syntax is desired email address on the left, and where to send the email to on the right.
The third line is an example of a single desired email address, on the right, being sent to multiple locations, on the left. Note that these address can be redirected to either a user or another email address.
The fourth line is an example of how to setup a catch-all account. The catch-all is on the left and the email address to redirect to is on the right.
Generating the Virtual Database
Once you have finished editing the virtual file, the next set is to generate the virtual database. Postfix does not read directly from the virtual file; it reads from a database based off of the content in the file.
The command to perform this function is:
postmap mydomain.com.virtual
The first part is the Postmap command that generates the database. The second part is the virtual file used to create the database.
Note: Changes made to the virtual files only becomes active after the database is generate.
Note: Postfix does not need to be reloaded for theses change to take effect. Only changes to main.cf require the reloading of postfix.
Create for New Domains
This section goes through setting up Postfix for a new domain or a domain that previously did not have email.
DNS Settings
There must be a valid MX record for the domain.
Create New Virtual File
Create and new virtual file and contents.
Update Main.cf
Add the location of the new virtual file to Main.cf. Reload PostfixReload Postfix for changes to take effect.