Difference between revisions of "Postfix"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
(some relevant open tabs)
(solution to local lack-of-aliasing problem)
Line 82: Line 82:
 
* Webmin seems to automatically run newaliases when you add or modify an individual alias, but ''not'' when you use it to edit the [[etc/aliases|/etc/aliases]] file directly. Changes made to /etc/aliases will not take effect until the database is updated.
 
* Webmin seems to automatically run newaliases when you add or modify an individual alias, but ''not'' when you use it to edit the [[etc/aliases|/etc/aliases]] file directly. Changes made to /etc/aliases will not take effect until the database is updated.
 
* Stopping and starting the postfix daemon does ''not'' update from the aliases file; you still have to run newaliases.
 
* Stopping and starting the postfix daemon does ''not'' update from the aliases file; you still have to run newaliases.
 
+
* If emails ''from outside'' are properly forwarded to their aliases but ''locally generated'' emails are "returned" as undeliverable with the error message "Diagnostic-Code: x-unix; user unknown", then make the following change in main.cf:
 +
** '''change''': {{link/subpage|pfx=/main.cf/|receive_override_options}} = no_address_mappings
 +
** '''to this''': receive_override_options =
 
===catch-all===
 
===catch-all===
To set up a catch-all address, edit [[/main.cf|main.cf]] and set the following parameters:
+
To set up a catch-all address, edit {{link/subpage|main.cf}} and set the following parameters:
* local_recipient_maps =
+
* {{link/subpage|pfx=/main.cf/|local_recipient_maps}} =
* luser_relay = <u>whereToSend</u>
+
* {{link/subpage|pfx=/main.cf/|luser_relay}} = <u>whereToSend</u>
  
 
The syntax for <u>whereToSend</u> is explained [http://www.postfix.org/postconf.5.html#luser_relay here].
 
The syntax for <u>whereToSend</u> is explained [http://www.postfix.org/postconf.5.html#luser_relay here].

Revision as of 15:14, 3 October 2010

About

Postfix is an open-source mail transfer agent (MTA) for POSIX systems. It is fully supported by Webmin and is part of the Dovecot stack.

Notes

After making changes to the Postfix configuration files, you don't actually have to stop and restart Postfix to load the changes; you can just type (as root) "postfix reload".

flow

There are multiple stages inside Postfix, and each stage can be affected by configuration parameters. I have not yet found a clear documentation of the data flow, but it seems to go like this (only much more complicated) under normal circumstances:

SMTP → Postfix delivery queue → user alias mappings → local delivery (MDA, e.g. Dovecot)

However, when using virtual (non-system) users, internally-generated emails (e.g. mail from cron or PHP's mail() function) seem to bypass the alias mappings, which the MDA then rejects if they are addressed to an alias instead of a user.

A table from the official documentation is more detailed, if perhaps less clear (where does the message end up? qmgr? how does it get delivered?):

trivial-
rewrite(8)

(std form)
trivial-
rewrite(8)

(resolve)
^
|
|
v
^
|
|
v
smtpd(8) >- cleanup(8) -> incoming -> active -> qmgr(8) -< smtp(8)
qmqpd(8) lmtp(8)
pickup(8) local(8)
^
|
^
|
|
v
bounces
forwarding
notices
deferred

aliases

To set up aliases, either edit the file specified by the alias_maps setting in main.cf (/etc/aliases by default) and then run newaliases (or "postalias /etc/aliases") to update the database, or else use Webmin ("Mail Aliases" icon, then click on the "Create a new alias" link).

Notes:

  • Webmin seems to automatically run newaliases when you add or modify an individual alias, but not when you use it to edit the /etc/aliases file directly. Changes made to /etc/aliases will not take effect until the database is updated.
  • Stopping and starting the postfix daemon does not update from the aliases file; you still have to run newaliases.
  • If emails from outside are properly forwarded to their aliases but locally generated emails are "returned" as undeliverable with the error message "Diagnostic-Code: x-unix; user unknown", then make the following change in main.cf:

catch-all

To set up a catch-all address, edit main.cf and set the following parameters:

The syntax for whereToSend is explained here.

Examples:

  • luser_relay = $user@anotherdomain.org
    • forwards all email addressed to "invaliduser@firstdomain.org" to "invaliduser@anotherdomain.org"
  • luser_relay = youraddress@anotherdomain.org
    • forwards all email addressed to invalid users to "youraddress@anotherdomain.org".

automatic BCC

To automatically BCC outgoing mail from any given set of users, set sender_bcc_maps in /main.cf to hash:/etc/postfix/sender_bcc. (In Webmin: BCC Mapping: Sender BCC mapping lookup tables)

Each line in the /sender_bcc file will contain the sender (which can be user@domain, user, or @domain), one or more blanks, then the recipient (which can be one address or multiple addresses separated by commas).

Example -- BCCs all mail sent by somedomain.com users to an archive address:

@vbz.com archive2024@vbz.com

pages to index

I have these open in tabs, so they are probably relevant to something:

Links

Official

Reference