From: postfix-users on
Noel Jones schrieb:
<a great explanation>

Everything is running fine :)

Thank you!

From: Ansgar Wiechers on
On 2010-04-08 postfix-users(a)tja-server.de wrote:
> Server A (MX, SMTP: smtp.example.com) has:
>
> relay_domains = $myhostname, localhost.$mydomain, localhost,
> /etc/postfix/mydomains

$myhostname and localhost.$mydomain should go into $mydestination, not
into $relay_domains. You can forward all mail to valid local addresses
to your internal host via entries in $alias_maps.

> relay_transport = smtp:[smtp.example.com]
> mynetworks = [ip.ad.dr.es], ...

I don't think [a.b.c.d] is valid syntax for IPv4 addresses in
$mynetworks. Lose the square brackets.

> Where /etc/postfix/mydomains lists all domains to be relayed

You may want to use a more "speaking" name for your relay domains (like,
/etc/postfix/relay_domains ;).

> and the relay_transport is the IP of Server B:

In your config snippet from server A, the parameter $relay_transport
doesn't contain the IP address of server B, but the FQDN of server A.
Unless you mis-obfuscated the parameter value you need to correct that
line.

> Server B (IMAP, imap.example.com) has:
>
> relayhost = [smtp.example.com]
> mydestination = $myhostname, localhost.$mydomain, localhost,
> /etc/postfix/mydomains
> mynetworks = [ip.ad.dr.es], ...

See above.

> This setup works for me - beside one problem:
>
> The /etc/aliases of Server A will not be honored, which means that all
> mail to any of the domains will be transported to Server B, which in
> turn will bounce the mail.

Expected, since you configured $myhostname as a relay domain.

> I would like to let already Server A bounce those mails!

# Server A
mydestination = $myhostname, localhost.$mydomain, localhost
relay_domains = /etc/postfix/relay_domains
alias_maps = hash:/etc/aliases
local_recipient_maps = $alias_maps
relay_recipient_maps = hash:/etc/postfix/relay_recipients

> Using a relay_recipient_maps as you wrote, seems to be the right way, but
> i cannot get it running.
>
> Like in a /etc/aliases file, i want to accept certain users for all domains.
>
> I tried to create the file as follows:
>
> awk -F: '{print $1}' /etc/aliases | egrep -v "^(#|$)" | awk '{print $1"@
> OK"}' | sort -u > relay_recipient_map

<cough>awk -F: '$0 !~ /^(#|$)/ {print $1" OK"}' /etc/aliases</cough>

> So, for example, it contains lines like:
>
> user1@ OK
> user2@ OK
>
> But this does not work :-(
>
> I would not like to list all users for all domains, but just accept
> mail to the existing users for ALL domains (as shown in my example
> above).
>
> Is there a way to reach that goal?
> Or do i need to add one line for each user in every domain?

The postconf man-page [1] isn't too clear about this, but I think you
need to specify full addresses (user1(a)example.com OK). I have a script
somewhere that will generate a list of valid recipients from various
(file-based) recipient and domain lists. If I manage to unearth it after
I get home tonight, I'll post it here.

[1] http://www.postfix.org/postconf.5.html#relay_recipient_maps

Regards
Ansgar Wiechers
--
"Abstractions save us time working, but they don't save us time learning."
--Joel Spolsky

From: Thomas on
Ansgar Wiechers schrieb:
> $myhostname and localhost.$mydomain should go into $mydestination, not
> into $relay_domains. You can forward all mail to valid local addresses
> to your internal host via entries in $alias_maps.

I changed than, thank you!
Also, i moved "localhost" to $mydestination, which i hope is OK ...


>
>> relay_transport = smtp:[smtp.example.com]
>> mynetworks = [ip.ad.dr.es], ...
>
> I don't think [a.b.c.d] is valid syntax for IPv4 addresses in
> $mynetworks. Lose the square brackets.

Yes, this was a formatting mistake, i have regular IPs and networks in
that line.


>> Where /etc/postfix/mydomains lists all domains to be relayed
>
> You may want to use a more "speaking" name for your relay domains (like,
> /etc/postfix/relay_domains ;).

I need a file with the same content on Server B, where it is referred to
by $mydestination
I did not want to use different names for files with the same content ...

>> and the relay_transport is the IP of Server B:
>
> In your config snippet from server A, the parameter $relay_transport
> doesn't contain the IP address of server B, but the FQDN of server A.
> Unless you mis-obfuscated the parameter value you need to correct that
> line.

But why?!?

It seems to work with the FQDN in square brackets:

relay_transport = smtp:[mail.example.com]


> Expected, since you configured $myhostname as a relay domain.

Yes, now it works better :)
Thank you again.

>> I would like to let already Server A bounce those mails!
>
> # Server A
> mydestination = $myhostname, localhost.$mydomain, localhost
> relay_domains = /etc/postfix/relay_domains
> alias_maps = hash:/etc/aliases
> local_recipient_maps = $alias_maps
> relay_recipient_maps = hash:/etc/postfix/relay_recipients

Der default, that seems to be quite similar already:

postconf | egrep "^(alias_maps|local_recipient_maps)"
alias_maps = hash:/etc/aliases
local_recipient_maps = proxy:unix:passwd.byname $alias_maps

I can locally expand now, with your suggestion for $mydestination :)


> <cough>awk -F: '$0 !~ /^(#|$)/ {print $1" OK"}' /etc/aliases</cough>

:)


> The postconf man-page [1] isn't too clear about this, but I think you
> need to specify full addresses (user1(a)example.com OK). I have a script
> somewhere that will generate a list of valid recipients from various
> (file-based) recipient and domain lists. If I manage to unearth it after
> I get home tonight, I'll post it here.

Thanx, but i already created a script - and my users dont change often -
the file will stay stable for months or even years now :9

Thank you for your comments and additional help!

From: Noel Jones on
On 4/8/2010 8:25 AM, Thomas wrote:
> Ansgar Wiechers schrieb:
>> $myhostname and localhost.$mydomain should go into $mydestination, not
>> into $relay_domains. You can forward all mail to valid local addresses
>> to your internal host via entries in $alias_maps.
>
> I changed than, thank you!
> Also, i moved "localhost" to $mydestination, which i hope is OK ...

Whether or not those domains belong in mydestination depends
on where you want them delivered. If they are to be delivered
on that physical box, mydestination is correct. If those
domains are to be sent on to the internal mailstore, then they
belong in relay_domains.

It's fairly common for a mail MX gateway to have an empty
mydestination setting.
# main.cf
mydestination =

But there is no one correct way; what you use depends on how
you want postfix to behave.

-- Noel Jones

From: Ansgar Wiechers on
On 2010-04-08 Thomas wrote:
> Ansgar Wiechers schrieb:
>>> Where /etc/postfix/mydomains lists all domains to be relayed
>>
>> You may want to use a more "speaking" name for your relay domains (like,
>> /etc/postfix/relay_domains ;).
>
> I need a file with the same content on Server B, where it is referred to
> by $mydestination
> I did not want to use different names for files with the same content ...

I suppose in that case I'd prefer to name the file "domains_COMPANYNAME"
or something, to avoid confusion with domains that are local to the
server. Perhaps a matter of personal opinion, though.

>>> and the relay_transport is the IP of Server B:
>>
>> In your config snippet from server A, the parameter $relay_transport
>> doesn't contain the IP address of server B, but the FQDN of server A.
>> Unless you mis-obfuscated the parameter value you need to correct that
>> line.
>
> But why?!?
>
> It seems to work with the FQDN in square brackets:
>
> relay_transport = smtp:[mail.example.com]

It should work if the FQDN is the FQDN of server B. It shouldn't work if
the FQDN is the FQDN of server A (which was the case in your config
snippet).

>>> I would like to let already Server A bounce those mails!
>>
>> # Server A
>> mydestination = $myhostname, localhost.$mydomain, localhost
>> relay_domains = /etc/postfix/relay_domains
>> alias_maps = hash:/etc/aliases
>> local_recipient_maps = $alias_maps
>> relay_recipient_maps = hash:/etc/postfix/relay_recipients
>
> Der default, that seems to be quite similar already:
>
> postconf | egrep "^(alias_maps|local_recipient_maps)"
> alias_maps = hash:/etc/aliases
> local_recipient_maps = proxy:unix:passwd.byname $alias_maps
>
> I can locally expand now, with your suggestion for $mydestination :)

The default includes all local users of the machine, which probably is
not what you want, considering the machine's purpose.

>> The postconf man-page [1] isn't too clear about this, but I think you
>> need to specify full addresses (user1(a)example.com OK). I have a script
>> somewhere that will generate a list of valid recipients from various
>> (file-based) recipient and domain lists. If I manage to unearth it after
>> I get home tonight, I'll post it here.
>
> Thanx, but i already created a script - and my users dont change often -
> the file will stay stable for months or even years now :9

'kay.

> Thank you for your comments and additional help!

You're welcome.

Regards
Ansgar Wiechers
--
"Abstractions save us time working, but they don't save us time learning."
--Joel Spolsky