1

Some processes on my server send mail to various system accounts which all goes to root on the local machine. I want the root account to be an alias for my (external) email address. I'm using exim4 version 4.86_2

I have the following in /etc/aliases:

mailer-daemon: postmaster
postmaster: root
nobody: root
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root
root: me@mydomain.com

I've run the "newaliases" command, but when I send a mail to "root" it goes to root@localdomain.

How can I make the server read /etc/aliases or send system mail out to an external email address?

  • Do you have config for exim for smarthost? – Romeo Ninov Feb 13 '19 at 16:30
  • I think, but I'm not sure that it may be to do with exim not knowing what the local host name is. Just reading this: https://unix.stackexchange.com/questions/235112/exim-email-to-root-ignores-etc-aliases-and-root-forward-always-used-qualif AH, yes it looks like that may have cured the problem – TommyPeanuts Feb 13 '19 at 16:32

2 Answers2

1

It turns out that the host didn't know what the canonical name of the machine was, so was assuming all local mail was in fact remote. I've fixed it now as per this answer.

0

exim do not refer to the system aliases by default. You have to create the router that lookup the /etc/aliases and forward the message accordingly. This router should look like that:

sys_alias:
    driver      = redirect
    data        = ${lookup{$local_part}lsearch{/etc/aliases}}
    user        = mailnull
    group       = mail
    file_transport  = address_file
    pipe_transport  = address_pipe
    allow_fail
    allow_defer

That router require the /etc/aliases file containing the lines of the next syntax:

localpart: alias
root:      user
other:     me@domain.tld
user:      john,mary,bob@other.tld

You can't use me@domain.tld: me@another.tld as far as lookup searching for localpart only. If you need to use the whole address instead of localpart you have to change the lookup condition accordingly.

Keep in mind that routers should be listed in the proper order.

Kondybas
  • 695
  • 5
  • 9
  • It is unclear what "router" means. Do you refer to a config file anywhere? – buhtz Dec 28 '20 at 21:05
  • @buhtz Routers are the basic exims concept. Refer to the specification of the exim, chapter 3 http://www.exim.org/exim-html-current/doc/html/spec_html/ch-how_exim_receives_and_delivers_mail.html – Kondybas Dec 28 '20 at 23:00