Forward local account mail to virtual user

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Forward local account mail to virtual user

Xylia Cipriano
Hello list,

I have setup Postfix with virtual users and MySQL. I have a few domains
and they all work great. I also added and alias "[hidden email]" and
sending a mail to the local root account results in a message in the
forwarding inbox (perfect).

However, when sending mail to the local postmaster account, an error
occurs (unknown user). The aliases file contains "postmaster: root", and
I assumed the following chain to work "postmater (local) --> root
(local) --> [hidden email] (virtual)". This is not the case.

How is the correct way to forward local e-mail to a virtual user? I like
the previously mentioned idea, that the local root account is virtually
aliases, and therefore the chain postmaster --> root --> virtual would
work. Is this possible?

Thank you!

--
Xylia Cipriano

PS: Debian wheezy with Postfix 2.9.6
PPS: In my main.cf: mydestination = localhost, localhost.localdomain
Reply | Threaded
Open this post in threaded view
|

Re: Forward local account mail to virtual user

Wietse Venema
Xylia Cipriano:

> Hello list,
>
> I have setup Postfix with virtual users and MySQL. I have a few domains
> and they all work great. I also added and alias "[hidden email]" and
> sending a mail to the local root account results in a message in the
> forwarding inbox (perfect).
>
> However, when sending mail to the local postmaster account, an error
> occurs (unknown user). The aliases file contains "postmaster: root", and
> I assumed the following chain to work "postmater (local) --> root
> (local) --> [hidden email] (virtual)". This is not the case.

What happens is:

postmaster@{any domain in $mydestination} is aliased to root@$myorigin

> How is the correct way to forward local e-mail to a virtual user? I like

In the local aliases file:

postmaster: [hidden email]

        Wietse

> the previously mentioned idea, that the local root account is virtually
> aliases, and therefore the chain postmaster --> root --> virtual would
> work. Is this possible?
>
> Thank you!
>
> --
> Xylia Cipriano
>
> PS: Debian wheezy with Postfix 2.9.6
> PPS: In my main.cf: mydestination = localhost, localhost.localdomain
>
Reply | Threaded
Open this post in threaded view
|

Re: Forward local account mail to virtual user

Viktor Dukhovni
In reply to this post by Xylia Cipriano
On Thu, Feb 26, 2015 at 02:08:53AM +0100, Xylia Cipriano wrote:

> I have setup Postfix with virtual users and MySQL. I have a few domains and
> they all work great. I also added an alias "[hidden email]" and sending a
> mail to the local root account results in a message in the forwarding inbox
> (perfect).
>
> However, when sending mail to the local postmaster account, an error occurs
> (unknown user). The aliases file contains "postmaster: root", and I assumed
> the following chain to work "postmater (local) --> root (local) -->
> [hidden email] (virtual)". This is not the case.

An unavoidable compromise is made in Postfix to maintain approximate
compatibility with Sendmail aliases(5) semantics.  Specifically,
when an alias resolves to a recipient whose address class is "local"
(domain matches $mydestination), that address is assumed local and
does not go through virtual alias rewriting.

> How is the correct way to forward local e-mail to a virtual user? I like the
> previously mentioned idea, that the local root account is virtually aliases,
> and therefore the chain postmaster --> root --> virtual would work. Is this
> possible?

Put an explicit domain on the RHS of the alias, making sure that the
domain in question is a virtual alias domain, or in any case not
listed in mydestination.

    aliases:
        postmaster: [hidden email]

    virtual:
        [hidden email] [hidden email]
        [hidden email] [hidden email]

Simpler however is to avoid local aliases(5) entirely except for
mailing lists with owner aliases and ":include:" member address
files (these are best handled in aliases(5) everything else is
better handled entirely in virtual(5)).

    virtual:
        [hidden email] [hidden email]
        [hidden email] [hidden email]

I also tend to keep mydestination almost empty, putting only
synthetic domains there (local.invalid or similar), and explicitly
rewrite selected addresses for local delivery.  In particular, I
try to make sure that $myorigin is not one of the "local" domains.

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: Forward local account mail to virtual user

Xylia Cipriano
On 02/26/2015 02:23 AM, Viktor Dukhovni wrote:

> Put an explicit domain on the RHS of the alias, making sure that the
> domain in question is a virtual alias domain, or in any case not
> listed in mydestination.
>
>      aliases:
> postmaster: [hidden email]
>
>      virtual:
> [hidden email] [hidden email]
> [hidden email] [hidden email]
>
> Simpler however is to avoid local aliases(5) entirely except for
> mailing lists with owner aliases and ":include:" member address
> files (these are best handled in aliases(5) everything else is
> better handled entirely in virtual(5)).
>
>      virtual:
> [hidden email] [hidden email]
> [hidden email] [hidden email]
>
> I also tend to keep mydestination almost empty, putting only
> synthetic domains there (local.invalid or similar), and explicitly
> rewrite selected addresses for local delivery.  In particular, I
> try to make sure that $myorigin is not one of the "local" domains.
>

Thank you for your quick reply! This (and Wietse's) answer solved the
issue.

One final question though: Is it possible (at all) to change only one
alias and get the all? Because the /etc/aliases file is mostly
maintained by Debian and I'd like to have mail forwarded automatically.
Most aliases are auto-created like, e.g., "clamav: root". So if root was
forwarded to [hidden email], that would be very nice because I would
not have to change anything after the system added that local alias. I
hope you know what I tried to ask.

If it's not possible, never mind -- it is just for convenience.

--
Xylia Cipriano
Reply | Threaded
Open this post in threaded view
|

Re: Forward local account mail to virtual user

Xylia Cipriano
In reply to this post by Wietse Venema
On 02/26/2015 02:16 AM, Wietse Venema wrote:
> What happens is:
>
> postmaster@{any domain in $mydestination} is aliased to root@$myorigin

Thanks, this explains the current behavior! I didn't notice this because
$myorigin is set to /etc/mailname (which, however, contains the domain,
as you suspected).

>
> In the local aliases file:
>
> postmaster: [hidden email]
>

Thanks again, this solves the problem!

I replied to the other mail in more detail and added a final question.

--
Xylia Cipriano
Reply | Threaded
Open this post in threaded view
|

Re: Forward local account mail to virtual user

Viktor Dukhovni
In reply to this post by Xylia Cipriano
On Thu, Feb 26, 2015 at 02:46:47AM +0100, Xylia Cipriano wrote:

> >In particular, I
> >try to make sure that $myorigin is not one of the "local" domains.
>
> One final question though: Is it possible (at all) to change only one alias
> and get the all? Because the /etc/aliases file is mostly maintained by
> Debian and I'd like to have mail forwarded automatically. Most aliases are
> auto-created like, e.g., "clamav: root". So if root was forwarded to
> [hidden email], that would be very nice because I would not have to change
> anything after the system added that local alias. I hope you know what I
> tried to ask.

To take advantage of (commit acts of indecency with?) the local
aliases file, you need to ensure that system accounts which are
qualified with $myorigin are resolved to the local(8) mailer by
virtue of $myorigin being one of the domains in $mydestination.

My advice is to convert all the Debian stock aliases(5) entries to
virtual(5) entries drop $myorigin/$myhostname from mydestionation
and move on.  Just set:

        mydestination = localhost, localhost.$mydomain

and rewrite only addresses that need special processing (list-manager
managed mailing lists mostly) to @localhost.  All other rewriting
can be based on virtual aliases.

Of course any account with an actual local mailbox (or that relies
on procmail or .forward files) still needs a rewrite to @localhost.

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: Forward local account mail to virtual user

Xylia Cipriano
On 02/26/2015 05:28 AM, Viktor Dukhovni wrote:

> To take advantage of (commit acts of indecency with?) the local
> aliases file, you need to ensure that system accounts which are
> qualified with $myorigin are resolved to the local(8) mailer by
> virtue of $myorigin being one of the domains in $mydestination.
>
> My advice is to convert all the Debian stock aliases(5) entries to
> virtual(5) entries drop $myorigin/$myhostname from mydestionation
> and move on.  Just set:
>
> mydestination = localhost, localhost.$mydomain
>
> and rewrite only addresses that need special processing (list-manager
> managed mailing lists mostly) to @localhost.  All other rewriting
> can be based on virtual aliases.
>
> Of course any account with an actual local mailbox (or that relies
> on procmail or .forward files) still needs a rewrite to @localhost.
>

Okay thanks, I'll spare me the trouble and exclusively use virtual
entries, just as you suggested. After all, I don't think any local user
will be added in future anyways.

--
Xylia Cipriano