POSTMULTI(1)

✨ POSTMULTI(1) ✨

okay bestie, gather round, because this is postmulti β€” the Postfix multi-instance manager, living its best life in the General Commands Manual section. πŸ’–


🌸 NAME 🌸

postmulti β€” Postfix multi-instance manager


πŸŽ€ SYNOPSIS πŸŽ€

Enabling multi-instance management:

postmulti -e init [-v]

Iterator mode:

postmulti -l [-ajRv] [-g group] [-i name]

postmulti -p [-av] [-g group] [-i name] postfix-command...

postmulti -x [-aRv] [-g group] [-i name] unix-command...

Life-cycle management:

postmulti -e create [-av] [-g group] [-i name] [-G group] [-I name]
[param=value ...]

postmulti -e import [-av] [-g group] [-i name] [-G group] [-I name]
[config_directory=/path]

postmulti -e destroy [-v] -i name

postmulti -e deport [-v] -i name

postmulti -e enable [-v] -i name

postmulti -e disable [-v] -i name

postmulti -e assign [-v] -i name [-I name] [-G group]

πŸ¦‹ DESCRIPTION πŸ¦‹

So postmulti(1) is THE tool that lets a Postfix administrator run and wrangle multiple Postfix instances on one single host. one host, many instances, zero chaos (ideally). ✨

And here's the tea: postmulti(1) has two fundamental modes of operation:

  • iterator mode β€” it runs the same command across multiple Postfix instances, one after another. group chat energy. πŸ’…
  • life-cycle management mode β€” it adds or deletes a single instance, or flips the multi-instance status of a single instance.

Each mode has its own command syntax, which is exactly why each mode gets its own section down below. no mixing, no confusion, periodt. πŸ‘‘


🌈 BACKGROUND 🌈

A multi-instance configuration is made of one primary Postfix instance, plus one or more secondary instances whose configuration directory pathnames get recorded in the primary instance's main.cf file. All the Postfix instances share program files and documentation, but each one has its own configuration, queue and data directories. sharing is caring, except for config. πŸ™ˆ

Now, the important caveat, no cap: currently, only the default Postfix instance can be used as the primary instance in a multi-instance configuration. The postmulti(1) command does not currently support a -c option to select an alternative primary instance, and it exits with a fatal error if the MAIL_CONFIG environment variable is set to a non-default configuration directory. so don't try it bestie, it will simply pass away. πŸ’€

If you want the full deep-dive discussion of multi-instance management with postmulti(1), go read the MULTI_INSTANCE_README tutorial. it's giving required reading. πŸ“š

⭐ ITERATOR MODE ⭐

In iterator mode, postmulti performs the same operation on all Postfix instances, in turn.

Small but mighty detail: if multi-instance support is not enabled, the requested command is performed just for the primary instance. simple life. 🫢

Iterator mode implements the following command options:

πŸ’œ Instance selection πŸ’œ

  • -a β€” Perform the operation on all instances. This is the default.
  • -g group β€” Perform the operation only for members of the named group.
  • -i name β€” Perform the operation only for the instance with the specified name. You can specify either the instance name or the absolute pathname of the instance's configuration directory. Specify "-" to select the primary Postfix instance.
  • -R β€” Reverse the iteration order. This may be appropriate when updating a multi-instance system, where "sink" instances are started before "source" instances.

This option cannot be used with -p.

πŸ“ List mode πŸ“

  • -j β€” Produce JSON output. See JSON OBJECT FORMAT below.

This feature is available in Postfix version 3.11 and later.

  • -l β€” List Postfix instances with their instance name, instance group name, enable/disable status and configuration directory.

🧚 Postfix-wrapper mode 🧚

  • -p postfix-command β€” Invoke postfix(1) to execute postfix-command. This option implements the postfix-wrapper(5) interface.
    • With "start"-like commands, "postfix check" is executed for instances that are not enabled. The full list of commands is specified with the postmulti_start_commands parameter.
    • With "stop"-like commands, the iteration order is reversed, and disabled instances are skipped. The full list of commands is specified with the postmulti_stop_commands parameter.
    • With "reload" and other commands that require a started instance, disabled instances are skipped. The full list of commands is specified with the postmulti_control_commands parameter.
    • With "status" and other commands that don't require a started instance, the command is executed for all instances.

The -p option can also be used interactively to start/stop/etc. a named instance or instance group. For example, to start just the instances in the group "msa", invoke postmulti(1) as follows:

# postmulti -g msa -p start

πŸ’– Command mode πŸ’–

  • -x unix-command β€” Execute the specified unix-command for all Postfix instances. The command runs with appropriate environment settings for MAIL_CONFIG, command_directory, daemon_directory, config_directory, queue_directory, data_directory, multi_instance_name, multi_instance_group and multi_instance_enable.

🌸 Other options 🌸

  • -v β€” Enable verbose logging for debugging purposes. Multiple -v options make the software increasingly verbose.

πŸ‘‘ LIFE-CYCLE MANAGEMENT MODE πŸ‘‘

With the -e option, postmulti(1) can be used to add or delete a Postfix instance, and to manage the multi-instance status of an existing instance. glow-up management, honestly. ✨

The following options are implemented:

🌟 Existing instance selection 🌟

  • -a β€” When creating or importing an instance, place the new instance at the front of the secondary instance list.
  • -g group β€” When creating or importing an instance, place the new instance before the first secondary instance that is a member of the specified group.
  • -i name β€” When creating or importing an instance, place the new instance before the matching secondary instance.

With other life-cycle operations, apply the operation to the named existing instance. Specify "-" to select the primary Postfix instance.

πŸŽ€ New or existing instance name assignment πŸŽ€

  • -I name β€” Assign the specified instance name to an existing instance, newly-created instance, or imported instance. Instance names other than "-" (which makes the instance "nameless") must start with "postfix-". This restriction reduces the likelihood of name collisions with system files.
  • -G group β€” Assign the specified group name to an existing instance or to a newly created or imported instance.

and that's where part 1 wraps... but hold on, bestie, we're not done yet β€” more of this page is coming right up. 🌈

okay so listen bestie πŸ’– this next bit is literally the main character of the whole page: actually creating, deleting and toggling instances. buckle up πŸŽ€

🌸 Instance creation/deletion/status change 🌸

  • -e action β€” this is the "edit" hook for all your managed instances, and the actions you can throw at it are these πŸ’…
    1. init β€” required first!! before postmulti(1) can manage anything at all. The postmulti -e init command updates the primary instance's main.cf file, and it does that by setting:
multi_instance_wrapper =
        ${command_directory}/postmulti -p --
multi_instance_enable = yes

and ngl if you'd rather set those yourself some other way, go off, that's totally allowed 🫢

  1. create β€” makes a brand-new Postfix instance and adds it to the multi_instance_directories parameter of the primary instance. The -I name option is what she recommends, bestie β€” it gives the instance a short name, and that name is used to construct the default values for the new instance's private directories. You can also pass the -G group option to put the instance in a group, but if you don't, the new instance just isn't a member of any group. simple as that ✨

The new instance's main.cf is the stock main.cf, except with the parameters that specify where the shared files live cloned over from the primary instance. For "nameless" instances though, you should manually adjust syslog_name so it gives you a unique "logtag" that starts with "postfix-" β€” that's the thing that'll uniquely identify the instance over in the mail logs. It's way simpler to just give the instance a short name with the -I name option, fr fr πŸ™ˆ

Optional "name=value" arguments let you specify the instance's config_directory, queue_directory and data_directory. Like, for example:

# postmulti -I postfix-mumble \
        -G mygroup -e create \
        config_directory=/my/config/dir \
        queue_directory=/my/queue/dir \
        data_directory=/my/data/dir

and if any of those pathnames isn't supplied, the program tries to generate the missing one(s) by taking the corresponding primary instance pathname and swapping the last pathname component out for the value of the -I option. cute, right? πŸ’…

Oh and β€” if the instance configuration directory already exists, and it's got both a main.cf and a master.cf file in it, then create will "import" the instance exactly as-is. For existing instances, create and import are literally identical. periodt.

  1. import β€” imports an existing instance into the list of instances being managed by the postmulti(1) multi-instance manager. This adds the instance to the multi_instance_directories list of the primary instance. If you provide the -I name option, it specifies the new name for the instance and is used to define a default location for the instance configuration directory (same deal as create above). The -G group option can be used to assign the instance to a group. And you can add a config_directory=/path argument to override a default pathname that's based on -I name πŸ‘‘
  2. destroy β€” destroys a secondary Postfix instance. To even be a candidate for destruction, an instance has to be disabled, stopped, and its queue has to have zero messages in it. And if you try to destroy the primary Postfix instance? that triggers a fatal error β€” it does not destroy the instance. 😭

The instance gets removed from the primary instance's main.cf file's alternate_config_directories parameter, and its data, queue and configuration directories get cleaned of the files and directories created by the Postfix system. The main.cf and master.cf files are removed from the configuration directory even if they've been modified since the instance was first created. And finally, the instance is "deported" from the list of managed instances.

If there are other files hanging out in the instance's private directories, those directories might not be fully removed, and a warning gets logged to alert the administrator. The expectation is that an instance built using "fresh" directories via the create action will be fully removed by the destroy action (as long as you disable it first). But if the instance's configuration and queue directories are populated with extra stuff (access and rewriting tables, chroot jail content, etc.), then the instance directories will not be fully removed. 🫠

⚠️ careful bestie β€” the destroy action triggers potentially dangerous file removal operations. Make absolutely sure the instance's data, queue and configuration directories are set correctly and do not contain any valuable files. like, seriously. πŸ’€
  1. deport β€” deports a secondary instance from the list of managed instances. This deletes the instance configuration directory from the primary instance's multi_instance_directories list, but it does not remove any files or directories. so it's like, a soft goodbye 🌸
  2. assign β€” assigns a new instance name or a new group name to the selected instance. Use -G - to specify "no group", and -I - to specify "no name". If you decide to make an instance "nameless", go set a suitable syslog_name in the corresponding main.cf file. iykyk πŸ’…
  3. enable β€” marks the selected instance as enabled. this literally just sets the multi_instance_enable parameter to "yes" in the instance's main.cf file. slay ✨
  4. disable β€” marks the selected instance as disabled. This means the instance won't be started etc. with "postfix start", "postmulti -p start" and so on. It can still be started etc. with "postfix -c config-directory start" though, so keep that in mind πŸ‘€

✨ Other options ✨

  • -v β€” turns on verbose logging for debugging purposes. and the way that multiple -v options stack?? each one makes the software increasingly verbose πŸ”₯

πŸ¦‹ JSON OBJECT FORMAT πŸ¦‹

The output is a sequence of lines. Each line contains one JSON object that represents the settings in a corresponding instance's main.cf file.

Object members have string values unless stated otherwise. Programs should ignore members that aren't listed here, because members may get added over time. πŸ’œ

  • name β€” the value of the corresponding multi_instance_name parameter, or "-" if no name is specified.
  • group β€” the value of the corresponding multi_instance_group parameter, or "-" if no group is specified.
  • enabled β€” either "y" or "n", depending on whether the corresponding multi_instance_enable parameter value is "yes" or "no".
note: this reports "y" for a primary instance, when multi-instance support is not enabled. 😭 (iconic quirk honestly)
  • config_directory β€” the value of the corresponding config_directory parameter.

🌈 ENVIRONMENT 🌈

The postmulti(1) command exports these environment variables before executing the requested command for a given instance, bestie:

  • MAIL_VERBOSE β€” this one gets set when the -v command-line option is present.
  • MAIL_CONFIG β€” the location of the configuration directory of the instance.

πŸ‘‘ CONFIGURATION PARAMETERS πŸ‘‘

  • config_directory (see postconf -d output) β€” the default location of the Postfix main.cf and master.cf configuration files.
  • daemon_directory (see postconf -d output) β€” the directory that holds Postfix support programs and daemon programs.
  • import_environment (see postconf -d output) β€” the list of environment variables that a privileged Postfix process will import from a non-Postfix parent process, or name=value environment overrides.
  • multi_instance_directories (empty) β€” an optional list of non-default Postfix configuration directories; these directories belong to additional Postfix instances that share the Postfix executable files and documentation with the default Postfix instance, and that are started, stopped, etc., together with the default Postfix instance.
  • multi_instance_group (empty) β€” the optional instance group name of this Postfix instance.
  • multi_instance_name (empty) β€” the optional instance name of this Postfix instance.
  • multi_instance_enable (no) β€” allow this Postfix instance to be started, stopped, etc., by a multi-instance manager.
  • postmulti_start_commands (start) β€” the postfix(1) commands that the postmulti(1) instance manager treats as "start" commands.
  • postmulti_stop_commands (see postconf -d output) β€” the postfix(1) commands that the postmulti(1) instance manager treats as "stop" commands.
  • postmulti_control_commands (reload flush) β€” the postfix(1) commands that the postmulti(1) instance manager treats as "control" commands, i.e. the ones that operate on running instances.
  • syslog_facility (mail) β€” the syslog facility of Postfix logging.
  • syslog_name (see postconf -d output) β€” a prefix that gets prepended to the process name in syslog records, so that, for example, "smtpd" becomes "prefix/smtpd".

Available in Postfix 3.0 and later:

  • meta_directory (see postconf -d output) β€” the location of non-executable files that are shared among multiple Postfix instances, such as postfix-files, dynamicmaps.cf, and the multi-instance template files main.cf.proto and master.cf.proto.
  • shlib_directory (see postconf -d output) β€” the location of Postfix dynamically-linked libraries (libpostfix-*.so), and the default location of Postfix database plugins (postfix-*.so) that have a relative pathname in the dynamicmaps.cf file.

πŸŽ€ FILES πŸŽ€

  • $meta_directory/main.cf.proto, stock configuration file
  • $meta_directory/master.cf.proto, stock configuration file
  • $daemon_directory/postmulti-script, life-cycle helper program

⭐ SEE ALSO ⭐

πŸ“ README FILES πŸ“

Use "postconf readme_directory" or "postconf html_directory" to locate this information.

  • MULTI_INSTANCE_README, Postfix multi-instance management

πŸ’œ HISTORY πŸ’œ

The postmulti(1) command was introduced with Postfix version 2.6. ✨

🧚 LICENSE 🧚

The Secure Mailer license must be distributed with this software.

✨ AUTHOR(S) ✨

okay so bestie, this whole masterpiece was not a solo project πŸ’– β€” it's giving collab energy, and these are the icons who built it. show some respect, they're literally the main characters of Postfix πŸ‘‘

  • Victor Duchovni β€” at Morgan Stanley πŸ’Ό
  • Wietse Venema β€” at IBM T.J. Watson Research P.O. Box 704 Yorktown Heights, NY 10598, USA πŸ“¬
  • Wietse Venema β€” also at Google, Inc. 111 8th Avenue New York, NY 10011, USA πŸŒ†
no cap, Wietse is on there twice β€” one man, two whole research empires, absolutely ate πŸ’… not me being obsessed with that level of range

and that's the whole page, fr fr 🫢 you made it to the very end, which is iconic of you. the lil footer down there signs it off as POSTMULTI(1) with the source/series and date stamped at the bottom right β€” go give it a lil kiss goodnight 😭✨

bye bestie, go configure something gorgeous πŸ’œπŸŒΈπŸ¦‹

πŸ“¦ where this page comes from