4

I have a mail server set up which is responsible for several virtual users and domains. These mails are delivered fine to the respective mailbox.

But I can't get local delivery for system accounts (root, http, ...) to work. This is my alias file:

root:           <local_user>
<local_user>:   <virtual_user@mydomain.org>

MAILER-DAEMON:  postmaster
postmaster:     root

bin:            root
daemon:         root
named:          root
nobody:         root
uucp:           root
www:            root
ftp-bugs:       root
postfix:        root
http:           root

This is the relevant part of /etc/postfix/main.cf:

alias_database = $alias_maps
alias_maps = hash:/etc/postfix/aliases
append_dot_mydomain = no
html_directory = no
inet_protocols = ipv4
mail_owner = postfix
mailq_path = /usr/bin/mailq
manpage_directory = /usr/share/man
mydestination = localhost.$mydomain, localhost, localhost.localdomain
mydomain = <mydomain.org>
myhostname = <myhost.mydomain.org>
mynetworks_style = host
myorigin = $mydomain
sendmail_path = /usr/sbin/sendmail
setgid_group = postdrop
unknown_local_recipient_reject_code = 550
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_gid_maps = static:5000
virtual_mailbox_base = /home/vmail
virtual_mailbox_domains = <mydomain.org mydomain2.org mydomain3.org ...>
virtual_mailbox_maps = hash:/etc/postfix/vmailbox

Values in <...> are obviously placeholders.

When I locally send a mail to root. Postfix completes the address to root@mydomain.org, which it then wants to deliver via virtual but of course root@mydomain.org is not a valid virtual address (and it should not be).

It would work if the address is completed to root@localhost for local delivery. But when sending emails.

How would I accomplish that? Or what else should I do to get local delivery to work? Thanks for your help.

/e: added mydomain = <mydomain.org> to above config output, because that wasn't obvious.

BubuIIC
  • 523
  • 5
  • 10

3 Answers3

1

Try adding to your mydestination definition

mydestination = localhost.$mydomain, localhost, localhost.localdomain, <mydomain.org>

Or, change the email to go to root@localhost.

Me, I stopped using local account for any email and have all system accounts configured as virtual domains. Then I can run email for the system using the same set of tools as I do for the virtual domains (and the mail is all stored in the same place).

I'm not sure that your current config will block email to root that comes from outside the box. You might want to test that.

Walter
  • 1,047
  • 7
  • 14
1

By default postfix will append $myorigin whenever the recipient part doesn't have valid domain. This behavior was controlled by append_dot_mydomain parameter (default: yes). You can read some rewriting schema that postfix do in this page.

Because myorigin was set as $mydomain, then you get behavior you described above

When I locally send a mail to root. Postfix completes the address to root@mydomain.org, which it then wants to deliver via virtual but of course root@mydomain.org is not a valid virtual address (and it should not be).


Solution

Change the myorigin to localhost.$mydomain. It will set the completion address to localhost.$mydomain. Because localhost.$mydomain was defined in mydestination then postfix will use /etc/aliases to perform aliasing.

masegaloeh
  • 17,978
  • 9
  • 56
  • 104
0

One solution is to just add the virtual domain (typically the fully qualified hostname) and virtual mailbox definitions for all of the local accounts that you want to allow to send mail.

tgharold
  • 609
  • 8
  • 19
  • I have considered that, but I don't want root@mydomain.org expsoed to the outside world. Only local delivery should be allowed to root. – BubuIIC Jun 03 '13 at 16:37
  • Take a look at http://www.postfix.org/RESTRICTION_CLASS_README.html -- you can setup per-address restriction lists. In our setup, we use root@, postgres@, etc. as convenient ways of gathering spam samples to feed to spamassassin's sa-learn. – tgharold Jun 03 '13 at 19:45