How to configure Postfix on Ubuntu 10.04

How to Configure Postfix on Ubuntu 10.04

Initial Postfix Installation and Configuration

First and foremost, I should advise that this article explains how to set up Virtual Domains that are not connected to Linux users. The premiere source of information on the subject, and as some in the IRC channel have called it, the word of god, is the official Postfix documentation.

The first step is to actually install Postfix:

sudo apt-get install postfix

Once installed, you must perform the basic configuration of Postfix required to successfully receive and send emails from your domain.

I suggest reviewing standard Postfix configuration principles to learn how to properly set up your domain name and relay hosts. For me, it was important to set up the mail relay for my application server, and to have the Postfix HELO set as my Mail Exchange DNS and rDNS.

Reverse DNS is exceptionally important, since major email hosts will automatically reject incoming mail from your IP address if your HELO does not precisely match the reverse DNS lookup.

Setting Up Virtual Domains Without Shell Access

Once the basic installation was done, I wanted to be able to create users under a variety of domains. Reviewing Postfix virtual MAILBOX examples for separate domains and non-UNIX accounts was the key to this quest. I chose this specific architecture because I wanted to minimize the attack surface on the server by strictly limiting the amount of valid user accounts. While there is a way to create users without shell access, I preferred not to create Linux system users at all, as it was a better reflection of the server's dedicated purpose.

The main point of this article is to highlight the critical configuration pieces I was initially missing, having completed the standard setup.

Troubleshooting Postfix Configuration Gaps

Here are the crucial steps I needed to finalize the setup:

1. Compile Virtual Database Files

I needed to go ahead and turn the /etc/postfix/vmailbox file and /etc/postfix/virtual file into compiled .db files, which Postfix requires to operate correctly.

sudo postmap /etc/postfix/vmailbox
sudo postmap /etc/postfix/virtual

I discovered this requirement because tailing the /var/log/mail.log file clearly showed missing database mappings as an issue.

2. Map the Correct UID and GID

I realized I had completely overlooked setting the correct User ID (UID) and Group ID (GID) for the Postfix user itself!

sudo cat /etc/passwd | grep postfix

This command revealed the correct IDs required for the virtual_uid_maps and virtual_gid_maps attributes within the /etc/postfix/main.cf configuration file.

3. Create Virtual Mailbox Directories

I reloaded Postfix, but emails were still not being delivered successfully. The virtual domains map to the base path on the file system set in the virtual_mailbox_base configuration. However, those directories did not exist yet.

sudo mkdir /var/mail/vhosts
sudo mkdir /var/mail/vhosts/winwinhost.com
sudo chown -R postfix:postfix /var/mail/vhosts

And that was it—those were the missing pieces. Always remember to tail the mail log; this will really help you identify exactly what is going wrong with the configuration. If you join the Postfix IRC channel, please remember to be courteous, use pastebin to expose your logs, and use complete sentences with proper grammar.

Frequently Asked Questions

How do I install Postfix on Ubuntu 10.04?

You can install Postfix on Ubuntu 10.04 using the APT package manager by running the command: sudo apt-get install postfix.

Why is reverse DNS important for Postfix?

Reverse DNS is crucial because many major email providers will reject mail from your IP address if the Postfix HELO configuration does not match the reverse look up.

How do I map virtual domains in Postfix without creating Linux users?

You can configure Postfix virtual mailboxes by specifying virtual_uid_maps and virtual_gid_maps attributes in main.cf, and mapping the vmailbox and virtual files to databases using postmap.