top of page
Writer's pictureSiddhesh Kadam

Creating Multiple Postfix Instances with Postmulti


POSTFIX

Postfix is a popular mail transfer agent (MTA) used to route and deliver email on Linux servers. Sometimes, it’s necessary to run multiple Postfix instances for different domains, applications, or services on the same server. This can be achieved using the postmulti tool, which allows you to configure and manage multiple Postfix instances easily.

In this guide, we'll walk through how to create and configure multiple Postfix instances using postmulti on a Linux-based system like Rocky Linux or RHEL.


What is postmulti?

postmulti is a utility that comes with Postfix and allows you to manage multiple Postfix instances. This tool creates separate configurations and directories for each instance, ensuring that they do not interfere with each other. Each instance can have its own configuration file, logs, queues, etc.


Step 1. Enable postmulti functionality on your Postfix server This command is required before postmulti can be used to manage Postfix instances. The "postmulti -e init" command updates the primary instance's main.cf file by setting:

multi_instance_wrapper = ${command_directory}/postmulti -p --multi_instance_enable = yes
[root@siddhesh ~]# postmulti -e init


Step 2. Create a New Postfix Instance


To create a new Postfix instance, use the postmulti tool with the -i flag to specify the name of the instance.

[root@siddhesh ~]#  postmulti -e create  -I postfix-stag1

This creates a new instance named postfix-stag1. The -e create option tells postmulti to create a new configuration and directory for the instance.

The above command creates a directory for the instance (e.g., /etc/postfix-stag1) with a separate configuration file, queue directory, etc.


Step 3. Configure the New Instance


Once the instance is created, you need to configure it. Each instance gets its own configuration directory. Edit the configuration file for the instance you just created.

[root@siddhesh ~]# grep 127.0.0.1:30 /etc/postfix-stag1/master.cf
127.0.0.1:30      inet  n       -       n       -       -       smtpd
[root@siddhesh ~]#

This configuration line ensures that Postfix listens for SMTP connections on 127.0.0.1 (localhost) using port 30. It defines a service that will handle SMTP traffic internally (no external access) for testing or local communication purposes.


Step 4. Enable the New Instance


To enable the new instance, use below command

[root@siddhesh ~]# postmulti -i postfix-stag1 -e enable

This command starts the instance with the settings you specified in its configuration file.


Step 5. Set necessary permissions to the newly created directory.

[root@siddhesh ~]# chown -R postfix:postfix /var/lib/postfix-stag1/
[root@siddhesh ~]# chmod 755 /var/lib/postfix-stag1/ -R

Step 6. Start the Postfix Instance

Now that the instance is created and enabled, you can start it using:

[root@siddhesh ~]# postfix -c /etc/postfix-stag1/ start

Step 7. Verify the New Instance


To verify that the new instance is running, you can check the status:

[root@siddhesh ~]# postfix -c /etc/postfix-stag1/ status
postfix-stag1/postfix-script: the Postfix mail system is running: PID: 3389671
[root@siddhesh ~]#

Step 8: Remove an Instance


If you no longer need an instance, you can remove it:

[root@siddhesh ~]#  postmulti -i postfix-stag1 -e disable
[root@siddhesh ~]# postfix -c /etc/postfix-stag1/ stop
[root@siddhesh ~]#  postmulti -i postfix-stag1 -e destroy

These command's will delete the instance's configuration and all associated files.


Conclusion

Running multiple instances of Postfix using postmulti allows you to have isolated configurations and mail queues for different applications or domains on the same server. This is useful for managing different mail services or running multiple email servers with varying configurations.





Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page