HOWTO set the local mailname used by exim4 to decided LOCAL or REMOTE delivery

From NHI1
Jump to: navigation, search

Setup

You use a exim4 to send external emails to your mails-services-provider (like validation email for user-account-creation) and in addition internal emails to a local admin-account.

Your setup is a host with two names, an external hostname:

  • external.mydomain

and an internal hostname:

  • internal.mynetwork

Problem

The cron-email, from a local user, is delivered by exim4 to your mail-service-provider → this is a problem because your local user in public unknown.

Your mail-service-provider send you a Undelivered Mail Returned to Sender message something like:

   This is the mail system at host mailhost.your-service-provider

   I'm sorry to have to inform you that your message could not
   be delivered to one or more recipients. It's attached below.

   For further assistance, please send mail to postmaster.

   If you do so, please include this problem report. You can
   delete your own text from the attached returned message.

Solution

/etc/mailname

Put the internal.mynetwork into this file and not the external.mydomain.

/etc/exim4/update-exim4.conf.conf

The exim4 configuration option dc_eximconfig_configtype have to be the value smarthost and not satellit. With satellit all emails (including the local ones) are send to your mail-service-provider.

dc_eximconfig_configtype
The main configuration type. Sets macro DC_eximconfig_configtype. The macro usually contains a shorthand for one of the choices for the “General type of mail configuration” debconf question (See README.Debian).

After configuration change restart the exim4 with:

  • sudo service exim4 restart

to be tested

The exim4 has a configuration option dc_other_hostnames.

dc_other_hostnames
is used to build the local_domains list, together with “localhost”. This is the list of domains for which this machine should consider itself the final destination. The local_domains list ends up in the macro MAIN_LOCAL_DOMAINS.

The problem is that just adding external.mydomain does not work - it seems the DNS-name-resolution just marked external.mydomain as external and the value from dc_other_hostnames is not used.