Postfix is a great mailer, but if you’re new to administering Postfix, finding your way around can be difficult. For example, just finding information on adding users to a Postfix system can be quite a trial.
In part, this is because Postfix can be set up in a number of ways. Some installations use Postfix alone, others use Postfix in conjunction with other apps and store user information in MySQL.
You can have users who have actual accounts on a system, or you can have users on virtual domains that don’t have a login but still receive mail. Or you might want aliases that include several users, so everybody on the “marketing” list gets mail or all folks in sales, legal, or development can receive messages.
For this tip, I’ll assume that you’ve inherited a Postfix domain and want a way to add users or aliases quickly.
Backup your files first!
If you’re new to Postfix, I strongly recommend making backups of your configuration files and setting up a test system in a virtual machine before making changes on a live mail server.
Postfix isn’t too hard to use, but it can be confusing if you’re new — and a slight error can stop mail delivery to one or more users far too easily.
How to add users
The simplest way to add a user is to add a new account on the system. Postfix will handle the rest. For example, on my server running Ubuntu, I’d just use adduser username
, and Postfix would automatically update parameters to send mail to that user, delivered locally.
But what if you don’t want to create a system account for the user? You should have a virtual domain set up that is not configured as a mydestination
domain. For more on this, be sure to read the Postfix guide on virtual domain hosting.
Users are then added in the form of user@domain
and then either saved in the mailbox on the system or handed off to Courier or another mail delivery program in the /etc/postfix/vmailbox
file.
However, if you don’t have a /etc/postfix/vmailbox
file, odds are your system was configured to deliver to local accounts. You should check /etc/postfix/main.cf
and look for the line mydestination
. If it includes the domain you’re adding users for, that means they’re being added as regular users.
Otherwise, in /etc/postfix/vmailbox
, add a line like:
jzb@mydomain.net mydomain.net/jzb
You should see some examples already. This will deliver mail to a mailbox called jzb in /var/mail/vhosts/mydomain.net — assuming your system is set up to deliver mail there. Note that you can store mail in an mdir format instead by adding a slash after the username.
Next, run postmap
against the file (/etc/postfix/vmailbox
) and postfix reload
to update the listing.
How to add an alias
To add an alias, go to /etc/aliases
and add the alias in either of the following ways:
- To add an alias to a local user:
alias: localuser
- To deliver mail to another domain:
alias2: user@remote.com
For example, if I want to send mail intended for “sales@my_domain.com” to a Gmail address, I can just add my Gmail account after the alias.
Bottom line: Postfix users and aliases
Remember, always make a backup of your configuration files, and whenever possible test any changes in a staging environment or virtual machine before implementing them in the Postfix directory.
With that caveat in place, this article should set you up to make any changes to Postfix users and aliases that your organization requires.
We evaluated the best cloud and online backup services to help you securely store your files and protect yourself against data loss.
Featured Partners: Back Up and Recovery Software
BDRSuite
Comprehensive and Cost-Effective Backup and Disaster Recovery Software for Virtual Machines (VMware, Hyper-V, KVM), Servers (Windows, Linux, NAS), Endpoints (Windows, Linux, Mac), SaaS Applications (Microsoft 365, Google Workspace), Cloud (AWS, Azure) and Applications (Microsoft Exchange, SQL, SharePoint, and MySQL). Flexible Recovery - Instant VM Restore, File Recovery, etc. Achieve RTO & RPO < 15 mins. Centralized Monitoring & Management. Tailored for SMBs, Enterprises, and Service Providers.
ManageEngine RecoveryManager Plus
RecoveryManager Plus is an integrated backup and recovery solution for your Exchange Online, on-premises Exchange, and Google Workspace mailboxes. Backup and restore all items in your mailboxes, including all attachments. Export entire Exchange Online and on-premises Exchange mailboxes or just a part of it as a PST file and secure them with a password for an additional layer of security. Try free for 30 days!