postfix: aliases will be ignored

Solution 1:

Not sure about what "my.domain" is exactly, but aliases are only used for local deliveries.

Instead, you probably want to use the virtual maps.

As root (or sudo)

In /etc/postfix/virtual (or where virtual is)

root    [email protected]

In main.cf

virtual_maps = hash:/etc/postfix/virtual

or (modern versions of postfix)

virtual_alias_maps = hash:/etc/postfix/virtual

after the virtual map has been modified

# postmap /etc/postfix/virtual
# postfix reload

Beware that all mail for "root" will be redirected to "[email protected]".

Solution 2:

In my case I want to use /etc/aliases (because some packages uses it so you have to verify changes and replicate to /etc/postfix/virtual

The problem why it doesn't work is in myorigin. If you set myorigin, all mails sent to root, nobody and other locals are changed automagicaly into root@myorigin

in my case: /etc/aliases:

nobody:   root
root: [email protected]

/etc/mailname:

myhost.example.com

/etc/postfix/main.cf:

myorigin = /etc/mailname
myhostname = othername.example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = othername, localhost.localdomain, localhost

In this case all mails sent to nobody are changed into [email protected] (because of myorigin) and then sent out somewhere.

I have to change mydestination:

mydestination = myhost.example.com, othername, localhost.localdomain, localhost

and now mail sent to nobody is redirected to root, which changes into [email protected], but because it is in mydestination it looks into aliases and changed into [email protected], but because it is in mydestination it looks into aliases, and redirected into [email protected], which isn't in mydestination and it is sent where it should be sent ;D