6

I have a server which is configured as a postfix MTA and on which runs also a munin node. In /etc/aliases I have add:

root:    hostmaster@my.domain

in the main.cf of postfix is configured:

mydomain = my.domain
myorigin = $mydomain
alias_database = hash:/etc/aliases
relay_domains = my.domain
append_at_myorigin = no
...

After each change of aliases or postfix configuration files I have called newaliases or postmap <cfgfile> and restart postfix.

Each time if munin will send a (error) email I get this in the maillog file:

Dec 22 16:45:19 myserver postfix/pickup[21509]: 5CFBA2011E0: uid=995  rom=<munin>
Dec 22 16:45:19 myserver postfix/cleanup[22094]: 5CFBA2011E0: 
    message-id=<20151222154519.5CFBA2011E0@my.domain>
Dec 22 16:45:19 myserver postfix/qmgr[21510]: 5CFBA2011E0: from=<munin>, size=999, nrcpt=1 
    (queue active)
Dec 22 16:45:20 myserver postfix/smtp[22099]: 5CFBA2011E0: to=<root@my.domain>, 
    orig_to=<root>, relay=internal.my.domain[XXX.182.189.136]:25, delay=4.2, 
    delays=3/0.01/1.1/0.09, dsn=5.1.1, status=bounced (host 
    internal.my.domain[XXX.182.189.136] said: 550 5.1.1 <root@my.domain>: Recipient address 
    rejected: User unknown in virtual mailbox table (in reply to RCPT TO command))
Dec 22 16:45:20 myserver postfix/cleanup[22094]: A98B72012D2: 
    message-id=<20151222154520.A98B72012D2@my.domain>
Dec 22 16:45:20 myserver postfix/bounce[22100]: 5CFBA2011E0: sender non-delivery 
    notification: A98B72012D2

Don't understand why "root" (orig_to) was not replaced with "hostmaster@my.domain" like it was specified in the aliases file. Seems postfix append the myorigin value to "root". Not sure why because I have also specified append_at_myorigin = no.

Whats going on here? I want to replace the "root" address with "hostmaster@my.domain". How can I do that?

11

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    hostmaster@my.domain

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 "hostmaster@my.domain".

3
  • Sure you mean virtual_maps? Or should it virtual_alias_maps?
    – Steffen
    Dec 22 '15 at 16:45
  • On my old postfix, main.cf has virtual_maps but the new manual indeed says virtual_alias_maps Dec 22 '15 at 16:49
  • 1
    virtual_maps works for me. At my first try I have forgotten the "s" (virtual_map instead of virtual_maps). Thanks al lot.
    – Steffen
    Dec 22 '15 at 16:58
12

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: admin@example.com

/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 nobody@myhost.example.com (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 nobody@myhost.example.com, but because it is in mydestination it looks into aliases and changed into root@myhost.example.com, but because it is in mydestination it looks into aliases, and redirected into admin@example.com, which isn't in mydestination and it is sent where it should be sent ;D

2
  • 2
    This is a better answer than the accepted one. Another example where local delivery works is shown here: arstechnica.com/information-technology/2014/03/…
    – Y2i
    Jan 30 '19 at 7:34
  • This is in fact a way better answer in the sense that it is getting to a solution that is using the de-facto standard /etc/aliases instead of diverging to the postfix-only /etc/postfix/virtual file.
    – he1ix
    Oct 27 '20 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.