mydestination, subdomains and local delivery

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

mydestination, subdomains and local delivery

vorname nachname
Hi all,

I'm running postfix for a domain, e.g, "testdomain.com". Its intended purpose is to receive mail for that domain and relay mail for authenticated users (e.g., to gmail), otherwise reject mail.

In main.cf, I have set "mydestination = testdomain.com". When sending mail to a certain user on that domain ([hidden email]), the mail gets delivered locally (no outbound connection). However, if I'm sending mail to [hidden email], postfix tried to relay the mail to an outbound server (namely that from my ISP). What I'd like to have is that mail for all subdomains being delivered locally, too. Can somebody give me a hint how to approach that problem?

Thanks!


Reply | Threaded
Open this post in threaded view
|

Re: mydestination, subdomains and local delivery

Wietse Venema
vorname nachname:

> Hi all,
>
> I'm running postfix for a domain, e.g, "testdomain.com". Its intended
> purpose is to receive mail for that domain and relay mail for authenticated
> users (e.g., to gmail), otherwise reject mail.
>
> In main.cf, I have set "mydestination = testdomain.com". When sending mail
> to a certain user on that domain ([hidden email]), the mail gets
> delivered locally (no outbound connection). However, if I'm sending mail to
> [hidden email], postfix tried to relay the mail to an
> outbound server (namely that from my ISP). What I'd like to have is that
> mail for all subdomains being delivered locally, too. Can somebody give me
> a hint how to approach that problem?

That's easy enough: use a regular-expression lookup table.

/etc/postfix/main.cf:
    mydestination =
        localhost $myhostname example.com pcre:/etc/postfix/mydestination.pcre

/etc/postfix/mydestination.pcre
   # This table is used as a 'list', therefore any non-empty RHS
   # value will work.
   /\.example\.com$/ whatever

How would Posfix know that a recipient is valid? With mydestination
the valid recipients are looked up in /etc/passwd and $alias_maps.

If you don't want to give everyone a UNIX shell account, see
http://www.postfix.org/VIRTUAL_README.html for alternatives.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: mydestination, subdomains and local delivery

vorname nachname
Thank you Wietse for the quick response - works like a charm!


2018-09-02 14:22 GMT+02:00 Wietse Venema <[hidden email]>:
vorname nachname:
> Hi all,
>
> I'm running postfix for a domain, e.g, "testdomain.com". Its intended
> purpose is to receive mail for that domain and relay mail for authenticated
> users (e.g., to gmail), otherwise reject mail.
>
> In main.cf, I have set "mydestination = testdomain.com". When sending mail
> to a certain user on that domain ([hidden email]), the mail gets
> delivered locally (no outbound connection). However, if I'm sending mail to
> [hidden email], postfix tried to relay the mail to an
> outbound server (namely that from my ISP). What I'd like to have is that
> mail for all subdomains being delivered locally, too. Can somebody give me
> a hint how to approach that problem?

That's easy enough: use a regular-expression lookup table.

/etc/postfix/main.cf:
    mydestination =
        localhost $myhostname example.com pcre:/etc/postfix/mydestination.pcre

/etc/postfix/mydestination.pcre
   # This table is used as a 'list', therefore any non-empty RHS
   # value will work.
   /\.example\.com$/ whatever

How would Posfix know that a recipient is valid? With mydestination
the valid recipients are looked up in /etc/passwd and $alias_maps.

If you don't want to give everyone a UNIX shell account, see
http://www.postfix.org/VIRTUAL_README.html for alternatives.

        Wietse