
qmgr Command in Linux
The qmgr command is a powerful utility provided by Postfix that allows administrators to manage the Postfix mail queue. It is responsible for controlling the flow of messages through the mail queue, ensuring efficient and reliable mail delivery. The qmgr command is used to manage the queue manager in the IBM MQ environment. It provides an interface for administrators to query and configure various aspects of the queue manager, such as creating and deleting queues, defining channels, and setting security attributes.
Table of Contents
Here is a comprehensive guide to the options available with the qmgr command −
- Understanding qmgr Command
- How to Use qmgr Command in Linux?
- Examples of qmgr Command in Linux
- Advanced Usage and Options
- Troubleshooting Tips for qmgr Command
Understanding qmgr Command
The qmgr command is a Postfix daemon that manages the mail queue. It is responsible for scheduling the delivery of messages, managing the flow of messages through the queue, and ensuring that messages are delivered efficiently. The qmgr daemon is designed to be run from the Postfix master process manager.
Prerequisites
Before we dive into the qmgr command, ensure you have the following −
- A Linux system with root or sudo access.
- Postfix installed on your system.
- Basic knowledge of Postfix and Linux command-line operations.
Install Postfix
If you haven't installed Postfix yet, you can do so using the following commands −
sudo apt update sudo apt install postfix -y

How to Use qmgr Command in Linux?
The qmgr command is typically run as a daemon and does not require direct user interaction. It is controlled through the Postfix master process manager and configured using the Postfix main configuration file (/etc/postfix/main.cf).
The basic syntax of the qmgr command is as follows −
qmgr [options]
Configuring qmgr
The qmgr daemon can be configured using various parameters in the Postfix main configuration file (/etc/postfix/main.cf). Here are some common configuration options −
qmgr_message_active_limit: Specifies the maximum number of messages in the active queue.
qmgr_message_active_limit = 20000
qmgr_message_recipient_limit: Specifies the maximum number of recipients per message in the active queue.
qmgr_message_recipient_limit = 1000
qmgr_fudge_factor: Specifies the fudge factor for message scheduling.
qmgr_fudge_factor = 100
Starting and Stopping qmgr
To start the qmgr daemon, use the following command −
sudo systemctl start postfix

To stop the qmgr daemon, use the following command −
sudo systemctl stop postfix
Verifying qmgr Status
To verify the status of the qmgr daemon, use the following command −
sudo systemctl status postfix

You should see output indicating that the Postfix service is active and running, and the qmgr daemon is listed as one of the running processes.
Examples of qmgr Command in Linux
Let's explore some detailed examples and explanations of the qmgr command and its usage.
Configuring qmgr for a Specific Network
To configure qmgr to accept connections only from a specific network, add the following lines to the Postfix main configuration file (/etc/postfix/main.cf) −
mynetworks = 127.0.0.0/8

This configuration allows qmgr to accept connections only from the 192.168.1.0/24 network.
Setting a Custom Timeout for qmgr
To set a custom timeout for qmgr, add the following line to the Postfix main configuration file (/etc/postfix/main.cf) −
qmgr_timeout = 600s
This configuration sets the timeout for qmgr to 600 seconds.
Limiting the Message Size for qmgr
To limit the message size for qmgr, add the following line to the Postfix main configuration file (/etc/postfix/main.cf) −
message_size_limit = 5120000
This configuration sets the maximum message size for qmgr to 5 MB.
Enabling Debugging for qmgr
To enable debugging for qmgr, add the following lines to the Postfix main configuration file (/etc/postfix/main.cf) −
debug_peer_level = 2 debug_peer_list = 192.168.1.100
This configuration enables debugging for connections from the 192.168.1.100 IP address.
Advanced Usage and Options
The qmgr command supports various advanced options that provide additional functionality and flexibility. Here are some commonly used options −
content_filter: Specifies a mail delivery transport that filters mail after it is queued.
content_filter = smtp:[127.0.0.1]:10024
receive_override_options: Enables or disables recipient validation, built-in content filtering, or address mapping.
receive_override_options = no_address_mappings
soft_bounce: Keeps mail queued that would otherwise be returned to the sender.
soft_bounce = yes
daemon_timeout: Specifies how much time a Postfix daemon process may take to handle a request before it is terminated by a built-in watchdog timer.
daemon_timeout = 18000s
Troubleshooting Tips for qmgr Command
Here are some common issues and troubleshooting tips for using qmgr −
Permission Issues
Ensure that the Postfix user has the necessary permissions to access the configuration files and directories. Use the chown command to set the appropriate ownership −
sudo chown -R postfix:postfix /etc/postfix

Configuration Errors
If qmgr fails to start, check the Postfix log files (/var/log/mail.log or /var/log/syslog) for configuration errors. Ensure that the main.cf and master.cf files are correctly configured.
Network Issues
Ensure that the firewall is configured to allow traffic on the QMQP port (default is 628). Use the following commands to configure the firewall −
sudo ufw allow 628 sudo ufw reload

Debugging
Enable debugging to get more detailed information about qmgr operations. Add the following lines to the Postfix main configuration file (/etc/postfix/main.cf) −
debug_peer_level = 2 debug_peer_list = 192.168.1.100
Conclusion
The qmgr command is a powerful tool for managing the Postfix mail queue. By following the steps outlined in this guide, you can configure, start, and manage the qmgr daemon with ease. This setup is particularly useful for efficiently transferring email messages between servers. With the ability to customize the configuration and monitor the qmgr daemon, you can ensure a reliable and efficient email delivery system on your Linux server.