PostfixAdmin Documentation
repository·master·Indexed 22 days ago
https://github.com/postfixadmin/postfixadminA web-based management interface for Postfix mail servers that allows administrators and users to manage domains, mailboxes, aliases, and quotas via SQLite, MySQL, or PostgreSQL backends. Features include support for DKIM storage, TOTP challenges, Application Specific Passwords, and integration with Dovecot, Courier, and Cyrus IMAP. Includes documentation on post-action hooks, Rspamd DKIM hooks, and a SquirrelMail plugin using the XMLRPC protocol.
What's inside PostfixAdmin
- PostfixAdmin is an open source, web-based interface designed to manage domains, mailboxes, aliases, and other mail-related configurations on a Postfix-based mail server. It acts as a management layer that integrates with mail servers and database backends to automate user and domain administration.
Overview of the SquirrelMail PostfixAdmin Plugin
masterThe PostfixAdmin SquirrelMail plugin allows users to manage their email settings directly from within the SquirrelMail webmail interface. Users can perform the following tasks:
- Vacation Mode: Turn vacation auto-responders on or off and manage vacation messages.
- Password Management: Change their email passwords.
- Forwarding Rules: Set up and manage virtual alias forwarding rules.
PostfixAdmin Features
masterPostfixAdmin provides several administrative and user-facing features:
Administrative Features
- Unlimited domains, aliases, and mailboxes.
- Optional storage quota support.
- Optional password expiry (beta).
- Multiple password hashing formats.
- Support for Domain Key (DKIM) storage.
- Optional XMLRPC-based API.
- Support for TOTP challenges (with optional IP address-based exemptions).
- Support for Application Specific Passwords (allowing multiple passwords per mailbox).
User Features
- User login and password management.
- Vacation / Autoresponder / Out Of Office setup.
- Integration with webmail clients like Squirrelmail or Roundcube via plugins.
- Retrieval of mail from a remote POP3 server via fetchmail.
How Virtual Vacation works
masterVirtual Vacation (an 'out of office' automated response) operates as a service within Postfix's
master.cfconfiguration.Workflow:
- When a user marks themselves as 'away', an alias is added to their account.
- This alias sends a copy of all incoming mail to a specific vacation service (e.g.,
user#domain.com@autoreply.domain.com). - Mail sent to the
@autoreply.domain.comdomain is intercepted by thevacation.plscript. - The script sends an automated reply based on configured settings. By default, a reply is only sent once per message.
Naming policy for custom fields and tables
masterTo prevent collisions with future PostfixAdmin updates, follow these naming conventions:
Extra fields in existing tables:
- Prefix field names with
x_. - Prefix any new indexes with
x_(ortablename_x_on PostgreSQL). - Avoid unique indexes and foreign keys where possible to simplify future schema changes.
Extra tables:
- Prefix table names with
x_. - Inside custom tables, you may use any names for fields and indexes.
- On PostgreSQL, index and unique-key names must start with
x_(e.g.,x_tablename_) because they are scoped to the schema. - Consider including
created,modified, andactivecolumns to match core tables.
- Prefix field names with
Add custom fields to PostfixAdmin entities using `*_struct_hook`
masterYou can add, modify, or remove fields from PostfixAdmin's built-in entities (domains, mailboxes, aliases, etc.) without modifying the core source code. This is achieved by using
*_struct_hookconfiguration callbacks.When a Handler is constructed, it looks for a configuration key named after its database table plus
_struct_hook. If a valid function name is provided, the Handler passes its$structarray through that function. The Handler then automatically builds the SQL queries and the web UI (add, edit, and list forms) based on the modified$struct.// Example of how the internal logic works $struct_hook = Config::read($this->db_table . '_struct_hook'); if (!empty($struct_hook) && is_string($struct_hook) && $struct_hook != 'NO' && function_exists($struct_hook)) { $this->struct = $struct_hook($this->struct); }Use the `dovecot:METHOD` hashing approach
masterIf PostfixAdmin does not natively support a specific format, you can use the
dovecot:METHODsyntax. This instructs PostfixAdmin to use thedoveadmsystem binary to generate the hash.Pros:
- Minimal dependency on PostfixAdmin/PHP code.
- Guaranteed compatibility with Dovecot.
Cons:
- Requires
proc_open()to be enabled in PHP. - Requires
doveadmto be installed and accessible by the web server. - May encounter permission or SELinux issues.
Example: If in doubt, try
dovecot:SHA512.How translation files are structured in PostfixAdmin
masterPostfixAdmin uses PHP files for translations, located in the
languages/directory with a.langextension (e.g.,languages/en.lang). The filelanguages/en.langserves as the canonical English source.Each translation file must start with
<?phpand contains an array of$PALANGassignments. Files must be UTF-8 encoded and may usehtmlentitiesfor special characters.<?php $PALANG['key'] = 'text';How the SquirrelMail PostfixAdmin Plugin communicates
masterThe plugin does not require direct access to the PostfixAdmin database. Instead, it communicates with PostfixAdmin using the XMLRPC protocol.
Security Requirement: Because the plugin uses XMLRPC, all traffic to the XMLRPC interface must be encrypted (e.g., via HTTPS). This encryption must be configured by the server administrator.
How Handler classes work in PostfixAdmin
masterHandler classes extend
PFAHandlerand provide a standardized way to manage database entities. Creating a Handler automatically enables support for:list.php: List and search views.edit.php: Create and edit forms.delete.php: Deletion logic.editactive.php: Toggling active status.postfixadmin-cli: Command-line interface access.
Lifecycle of a Handler
- Instantiation:
list.phporedit.phpcreates the instance:new FooHandler($new, $username, $is_admin). - Initialization: The constructor calls
initStruct()andinitMsg(), and sets up$allowed_domains. - Edit Flow: For existing items,
init($id)loads the data. When saving,set($values)validates input, andsave()writes to the database. - Save Flow:
save()executespreSave(), performs the SQL INSERT/UPDATE, and then executespostSave(). - List Flow:
getList($condition)triggersbuild_select_query()$\rightarrow$read_from_db()$\rightarrow$read_from_db_postprocess().
PostfixAdmin Integration and Compatibility
masterPostfixAdmin is designed to work within a standard mail stack. It integrates with:
- Mail Servers: Postfix and IMAP/POP3 servers (such as Dovecot or Courier).
- Database Backends: Choose one of
SQLite,MySQL, orPostgreSQL. - Optional Components: Fetchmail (for retrieving mail from remote POP3 servers).
Setup a Database
masterCreate a database for PostfixAdmin. Below are the command-line instructions for common database types:
MySQL/MariaDB
CREATE DATABASE postfix; CREATE USER 'postfix'@'localhost' IDENTIFIED BY 'choose_a_password'; GRANT ALL PRIVILEGES ON `postfix` . * TO 'postfix'@'localhost'; FLUSH PRIVILEGES;PostgreSQL
CREATE USER postfix WITH PASSWORD 'whatever'; CREATE DATABASE postfix OWNER postfix ENCODING 'unicode';SQLite Create a directory and a database file, ensuring the web server user (e.g.,
www-data) has write permissions to both:mkdir /srv/postfixadmin/database touch /srv/postfixadmin/database/postfixadmin.db sudo chown -R www-data:www-data /srv/postfixadmin/database