Short report:
Please do not set 'myorigin = /etc/mailname' at least for
"Internat with smarthost". This may cause root mail etc. to be sent
outside unless user checks result of debconf carefully.
Long report:
"postfix/main_mailer_type" has 5 possible values:
No configuration:
Should be chosen to leave the current configuration unchanged.
Internet site:
Mail is sent and received directly using SMTP.
Internet with smarthost:
Mail is received directly using SMTP or by running a utility such
as fetchmail. Outgoing mail is sent using a smarthost.
Satellite system:
All mail is sent to another machine, called a 'smarthost', for delivery.
Local only:
The only delivered mail is the mail for local users. There is no network.
So natuarally, except for "Satellite system", I expect no system mail to
be forwarded to smarthost in default set up.
Since policy states, /etc/mailname to be:
---
Such package should check for the existence of this file when it is being
configured. If it exists, it should be used without comment, although an MTA's
configuration script may wish to prompt the user even if it finds that this
file exists. If the file does not exist, the package should prompt the user for
the value (preferably using debconf) and store it in /etc/mailname as well as
using it in the package's configuration. The prompt should make it clear that
the name will not just be used by that package. For example, in this situation
the inn package could say something like:
Please enter the "mail name" of your system. This is the
hostname portion of the address to be shown on outgoing
news and mail messages. The default is
syshostname, your system's host name. Mail
name ["syshostname"]:
where syshostname is the output of hostname --fqdn.
---
I expect the value in this /etc/mailname to be used for *outgoing* news
and mail messages. For "Internet with smarthost", I expect to use such
address as ISP "pacbell.com" or forwarding address "debian.org". All
local mail such as ones to root end up in local host.
When postfix "Template: postfix/mailname" asked me without *outgoing*:
---
Description: System mail name:
The "mail name" is the domain name used to "qualify" mail addresses
without a domain name.
.
This name will also be used by other programs. It should be the
single, fully qualified domain name (FQDN).
.
Thus, if a mail address on the local host is foo@example.org,
the correct value for this option would be example.org.
---
I have only one account with matching my debian account name on this
machine where outgoing mail is generated. Naturally I put "debian.org"
in this question instead of $(hostname --fqdn). This set up
/etc/mailname to "debian.org" and set 'myorigin = /etc/mailname'. (This
is normal reaction by many home users without domain registration etc.
using smarthost set up behind the broad band router.)
Then, when "postfix/destinations" asked me:
---
Description: Other destinations to accept mail for (blank for none):
Please give a comma-separated list of domains for which this machine
should consider itself the final destination. If this is a mail
domain gateway, you probably want to include the top-level domain.
---
Although "debian.org" was included in the list, I eliminated it since I do not
want mails to my fellow DD end up in my machine as undelivarable.
Alas, this seemingly normal system end up with very bad situation. Some cron
job message to root was sent out to my smarthost and to "root@debian.org".
I understand
* what you ask in debconf and
* what you setup as "myorigin = /etc/mailname"
match up. So I should have placed "localhost" or $(hostname --fqdn)
which was "snoopy.invalid" in my case into the query.
I think postfix should follow policy for /etc/mailname. I should be
able to set it to my ISP or debian.org wthout problem.
The valid return address is required to get mail delivered over spam
prevention. (As everyone knows these days, such invalid mail address
will be rejected by many MTA.) For this end, generic(5) serves address
rewriting for outgoing mail for postfix.
I think, at least for "Internet site" and "Internet with smarthost", we
should set up "myorigin" as either one of:
# postconf -e "myorigin = $(hostname --fqdn)"
or
# postconf -e 'myorigin = localhost'
Then in my case by manual configuration for postfix 2.3:
# vim /etc/postfix/generic
... make table
# postmap /etc/postfix/generic
# postconf -e 'smtp_generic_maps = hash:/etc/postfix/generic'
Since this is a bit too complicated for installation script, I suggest
something along following script to generate /etc/postfix/generic after
setting /etc/mailname with policy compliant quesry with *outgoing* in
the postinst (after checking file alteration, main.cf sanity check etc.)
---
cat >/etc/postfix/generic <<EOF
# This is debconf generated address rewriting routine for outgoing mail
# If you want to set up more fine grained rewriting rule, please read
# generic(5).
# Please indicate below by substituting No to Yes if you edit this:
# Manual_change = No
/^\\([^@]*\\)\$/x \$1@$(cat /etc/mailname)
/^\\([^@]*\\)@.*\$/x \$1@$(cat /etc/mailname)
EOF
---
(I hope my escaping was OK for '\'s .)
Then set up postfix (main.cf) with:
# postconf -e 'smtp_generic_maps = regrex:/etc/postfix/generic'
This is a bit complicated and I think there may be simpler way to
prevent local mail to go outside, this at least gave me sane system.
When you do this, please consider to include /etc/postfix/sasl_passwd
with dummy contents:
---
# Please read (postfix-doc package) /usr/share/doc/postfix/SASL_README.gz
# under "Enabling SASL authentication in the Postfix SMTP client" for
# details. Run postmap(5) after updating this file.
# Format:
#[targetmailserver.example] login:password
#[targetmailserver.example]:587 login:password
#
---
I think this smarthost fix is needed to get postfix to be real
alternative to exim4 :-)
FYI:
In case of exim4, they use /etc/email-addresses for fine grained
outgoing mail address rewrining. But that was not needed if
/etc/mailname was set to some valid mail domain name as long as you use
one mail domain for all accounts. All local mail was delivered without
problem.