Handling mail for multiple virtual domains with exim4

Posted by Steve on Mon 16 May 2005 at 15:46

Many mail servers need to handle mail for multiple virtual domains. This can easily be achieved with Sendmail, postfix, or qmail. Here we'll cover how it's done with exim4 - the default mailserver for Sarge.

This is an update to a previous article here: Handling mail for multiple domains with exim3.

The upgrade from Exim3, the default mailserver for Woody, to Exim4, the default mail server for Sarge is a fairly painless process.

We covered the upgrade process in upgrading from Woody to Sarge: Part 3 - Exim4, but just to recap:

  • There are two main exim4 packages to choose from:
    • exim4-daemon-light - A basic and functional server.
    • exim4-daemon-heavy - A more complex server with advanced features.
  • When using the exim4 package you have two choices:
    • Use a single monolithic configuration file (As exim3 used).
    • Using a split configuration system with a lot of small files.
Installing Exim4 - if you need to

Because I'm going to want to scan incoming mail for viruses as they are delivered, rather than filter them out myself once I've accepted them I will install the heavy version of the server:

root@lappy:~# apt-get install exim4-daemon-heavy 
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
  exim4-base exim4-config
Suggested packages:
  eximon4 exim4-doc-html exim4-doc-info
The following NEW packages will be installed:
  exim4-base exim4-config exim4-daemon-heavy
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 1033kB/1450kB of archives.
After unpacking 1155kB of additional disk space will be used.
Do you want to continue? [Y/n] 

Once this has downloaded you will start the debconf configuration process.

The first question asked is 'Do you wish to use a single monolithic configuration file, or split files?' Here I chose the split file approach, to make future upgrades more simple.

Once that was done you're left to choose the type of configuration you wish to use - I chose "an internet site", because I want to send and receive mail directly. This choice does affect the subsequent questions you'll have.

Choosing the mail name should be obvious, as should choosing which addresses you wish the server to listen upon.

Once that's done the basic setup is complete - but we've still got to handle the virtual domain setup.

Handling Virtual Domains

If you've just installed the server and you followed the debconf setup I did then you'll have a server which will send and receive mail for a single domain.

The way that I've chosen to handle virtual domain mails, (which was used in the exim3 article) is to have a text file for each domain which contains a mapping between the email address and a local user.

For example assume you wish to handle mail for three domains:

  • example.net
  • example.org
  • example.com

Create three text files:

  • /etc/exim4/virtual/example.net
  • /etc/exim4/virtual/example.org
  • /etc/exim4/virtual/example.com

Each file will contain lines of the form:

address : username@localhost

Where "address" is the part of the email address to the left of the domain name, and "username" is the account name on the local system which should recieve that mail.

To make it more clear assume:

  • Alice gets all mail sent to example.net.
  • Bob gets all mail sent to example.org.
  • Eve has a mail account at example.com, as does Trent.

This gives /etc/exim4/virtual/example.com:

eve : eve@localhost
trent : trent@localhost

For Bob who has a "catchall" address setup for example.org - /etc/exim4/virtual/example.org:

* : bob@localhost

And similarly for Alice - /etc/exim4/virtual/example.net:

* : alice@localhost

You can also drop all mail for a user by using:

eve : :blackhole:

Or to generate a bounce with some text added so that the sender will know why they got it:

sharon : :fail: She no longer lives here.

Now we just need to make exim4 read these files to know what to do with the incoming mail, a simple enough job.

First of all we need to update the list of domains we handle mail for by editing the file /etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs, change the current "local_domains" with this one:

domainlist local_domains = @:localhost:dsearch;/etc/exim4/virtual

This will cause the local_domains setting to include the domain list from the directory we've specified. (Which is why the text files are named after the domain name to which they apply).

Now that the list of domains has been updated we need to create a new file - edit the file /etc/exim4/conf.d/router/350_exim4-config_vdom_aliases and add the following contents to it:

vdom_aliases:
      driver = redirect
      allow_defer
      allow_fail
      domains = dsearch;/etc/exim4/virtual
      data = ${expand:${lookup{$local_part}lsearch*@{/etc/exim4/virtual/$domain}}}
      retry_use_local_part
      pipe_transport   = address_pipe
      file_transport   = address_file
      no_more

Here we tell exim how to lookup the local recipients.

Once this has been done you can restart the server and see how it works:

/etc/init.d/exim4 restart

 

 


Posted by davee (80.68.xx.xx) on Thu 19 May 2005 at 14:09
Excellent.

I'm just setting up a new mail server and this is exactly what we will want to do. Very useful ... thanks Steve.

[ Parent | Reply to this comment ]

Posted by Anonymous (216.191.xx.xx) on Thu 19 May 2005 at 18:07
Hi,

Thanks for this great tutorial. That's exacly what I need !

Now I would like to know if there is a way to tell exim to use the userdb file instead of /etc/passwd to deliver user mail ?

Thanks again. Laurent

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Fri 20 May 2005 at 06:32
[ View Steve's Scratchpad | View Weblogs ]

It should be very simple to setup exim to take the local users from any file - not just /etc/passwd. But because I'm not sure what you mean by userdb I can't help.

Exim will lookup against databases, LDAP, or text files. There's a lot of great documentation over at exim.org which you might find useful to skim.

Steve
-- Steve.org.uk

[ Parent | Reply to this comment ]

Posted by Anonymous (216.191.xx.xx) on Fri 20 May 2005 at 13:31
Hi Steeve,

Thanks for your answer.
userdb is the file (or directory) used by courier-imap to know my virtual users in my virtual domains.
For the moment I have a file /etc/exim4/virtual/exemple.com which contains vuser : vuser@localhost (I followed your example)
and a file /etc/courier/userdb/example.com which contains
check.conf@example.com imappw=XXXXXXXX|uid=130|mail=/var/spool/vmail/domains/example.com /check.conf|home=/var/spool/vmail|gid=65534

Since the configuration files are really different I asked myself if it is possible to have only one file for the two configurations. That will be nice.
I will check the exim doc. Thanks.

[ Parent | Reply to this comment ]

Posted by chris (217.8.xx.xx) on Tue 31 May 2005 at 06:54
[ View Weblogs ]
So close to switching MX to the new exim4 based box. This article got virtual hosts for me, and I've managed to get mailman integrated as per the FAQ on the exim site too.

One question remains - and is to do with virtual hosting.

The server recognizes all domains with a file in /etc/exim4/virtual.

Two examples.

Mail to user1@domain1.tld should be delivered to a local user fred

Mail to user2@domain1.tld should be delivered to a remote user bill@totallyotherhost.tld

Any other mail to domain1.tld should be delivered to local user alice
user1 : fred@localhost
user2 : bill@totally_other_host.tld
* : alice@localhost

mail to user1 is delivered to fred
mail to user2 is delivered to alice
any other mail is delivered to alice

Now - for 4 of the 5 domains - the remote user line is not an issue - since they only have local users - but - for the fifth one - perhaps 95% of the addresses are remote.

This is a migration of a very large sendmail virtusertable.

Any hints?

[ Parent | Reply to this comment ]

Posted by chris (217.8.xx.xx) on Tue 31 May 2005 at 06:57
[ View Weblogs ]
This is being tested (run as root):

# exim4 -bt user2@domain.tld
system_aliases for alice@localhost
userforward for alice@localhost
procmail for alice@localhost
maildrop for alice@localhost
local_user for alice@localhost
alice@localhost
    <-- user2@domain.tld
  router = local_user, transport = maildir_home

I may be testing incorrectly - so - hints on that too :)

[ Parent | Reply to this comment ]

Posted by chris (217.8.xx.xx) on Tue 31 May 2005 at 07:38
[ View Weblogs ]
OK - this goes down as my "this months stupid config error".

Big note to self:

Format for virtual hosts lines is

user : user@domain

Not

user@domain : user@domain

Grumble grumble.

[ Parent | Reply to this comment ]

Posted by Anonymous (82.68.xx.xx) on Sat 11 Jun 2005 at 23:38

I transitioned to exim4 last week, but I had to modify it to match my existing exim3 virtual domain set-up. Basically this allows for local part suffix support for aliases (e.g. allow addresses such as user-suffix@example.com) but to also allow suffix matching addresses to be fully specified in the alias file (e.g. user-spam: :blackhole: )

I've put the following in routers/350_local_vdom_routers. I believe it's good admin practice to use "local" as the package identifier for locally added files, rather than "exim4-config". (as used above)

# Virtual domain router
# split into two routers to allow you to reject a suffix address from
# inside the aliases file

vdom_aliases:
  debug_print = "R: vdom_aliases for $local_part@$domain"
  driver = redirect
  allow_defer
  allow_fail
  domains = dsearch;/etc/exim4/virtual
  data = ${expand:${lookup{$local_part}lsearch*@{/etc/exim4/virtual/$domai n}}}
  retry_use_local_part
  pipe_transport   = address_pipe
  file_transport   = address_file

vdom_aliases_suffix:
  debug_print = "R: vdom_aliases_suffix for $local_part@$domain"
  driver = redirect
  allow_defer
  allow_fail
  domains = dsearch;/etc/exim4/virtual
  data = ${expand:${lookup{$local_part}lsearch*@{/etc/exim4/virtual/$domai n}}}
  local_part_suffix = -*
  local_part_suffix_optional
  retry_use_local_part
  pipe_transport   = address_pipe
  file_transport   = address_file
  no_more

[ Parent | Reply to this comment ]

Posted by mark (62.30.xx.xx) on Mon 22 Oct 2007 at 17:12
I tried this out but it doesn't support ".forward" files

Because, I guess, the userforward router does a check_local_user and of course these virtual users won't be in /etc/passwd? My virtual users are stored in Courier-Imap's userdb but after 87 years of googling I still havn't found a howto that integrates the two fully.

My .forward files are set to run in "# Exim filter" mode so they can file mailing list messages, and not least dreaded spam into specific folders. Pretty essential these days I'd say.

I quite like the scheme here otherwise, but I'll be forced to dump the whole thing if I can't get ".forward" support for virtual users. Maybe I have to mess around with a MySQl solution now...Isn't email admin such fun?

Any ideas? I'm newish to Exim.

[ Parent | Reply to this comment ]

Posted by chris (213.187.xx.xx) on Tue 8 Apr 2008 at 06:36
[ View Weblogs ]
Just tried this. Added the vdom_aliases_suffix: router and restarted exim.
bryanek:/etc/exim4/conf.d/router# exim4 -bt astrid@chrissearle.org
R: system_aliases for astrid@localhost
R: userforward for astrid@localhost
R: procmail for astrid@localhost
R: maildrop for astrid@localhost
R: local_user for astrid@localhost
astrid@localhost
    <-- astrid@chrissearle.org
  router = local_user, transport = maildir_home
bryanek:/etc/exim4/conf.d/router# exim4 -bt astrid+foo@chrissearle.org
R: system_aliases for chris@localhost
R: userforward for chris@localhost
R: procmail for chris@localhost
R: maildrop for chris@localhost
R: local_user for chris@localhost
chris@localhost
    <-- astrid+foo@chrissearle.org
  router = local_user, transport = maildir_home
Doesn't look like local part suffix support is working for me :( Here's my config piece:
vdom_aliases:
      driver = redirect
      allow_defer
      allow_fail
      domains = dsearch;/etc/exim4/virtual
      data = ${expand:${lookup{$local_part}lsearch*@{/etc/exim4/virtual/$domai n}}}
      retry_use_local_part
      pipe_transport   = address_pipe
      file_transport   = address_file

vdom_aliases_suffix:
      driver = redirect
      allow_defer
      allow_fail
      domains = dsearch;/etc/exim4/virtual
      data = ${expand:${lookup{$local_part}lsearch*@{/etc/exim4/virtual/$domai n}}}
      local_part_suffix = +*
      local_part_suffix_optional
      retry_use_local_part
      pipe_transport   = address_pipe
      file_transport   = address_file

[ Parent | Reply to this comment ]

Posted by chris (82.196.xx.xx) on Tue 8 Apr 2008 at 07:53
[ View Weblogs ]
Give me enough time to think about this and I'll work it out in the end :)

When you are transferring from using a catchall to foo+bar addresses - remember to remove the catchall from the virtual files used in vdom_aliases - as otherwise it *will* catch.

[ Parent | Reply to this comment ]

Posted by Anonymous (81.130.xx.xx) on Sat 2 Jul 2005 at 14:24
Hi,
I'm running Sarge on a bytemark vm. When I attempt to upgrade from exim 4 light to heavy using apt-get I'm not given the option of a spilt installation. How can I upgrade to a spilt installation in thsi case??

Pete

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Sat 2 Jul 2005 at 17:11
[ View Steve's Scratchpad | View Weblogs ]

Run:

dpkg-reconfigure exim4-config

Steve
-- Steve.org.uk

[ Parent | Reply to this comment ]

Posted by Anonymous (81.130.xx.xx) on Sun 3 Jul 2005 at 07:35
Hi Steve,
Have followed the the above but get the following error msg when I restart exim. I setup the config to send via the bytemark smarthost. Rgs Pete

The error reads: Restarting MTA: 2005-07-03 07:28:22 Exim configuration error in line 420 of /var/lib/exim4/config.autogenerated.tmp:
option setting expected: ${expand:${lookup{$local_part}lsearch*@{/etc/exim4/virtual/$domai n}}}
Invalid new configfile /var/lib/exim4/config.autogenerated.tmp
not installing /var/lib/exim4/config.autogenerated.tmp to
/var/lib/exim4/config.autogenerated
compassweb:/etc/exim4/conf.d/router#


[ Parent | Reply to this comment ]

Posted by compass (81.130.xx.xx) on Sun 3 Jul 2005 at 07:51
Hi Steve,
Please ignore the above post, have corrected MY OWN mistake and exim is now working fine. Keep up the good work - Rgs Pete

[ Parent | Reply to this comment ]

Posted by Anonymous (62.3.xx.xx) on Thu 7 Jul 2005 at 21:35
This is a really great article and works quite well. Only one question: is it possible to forward the email for a specific user to a Maildir instead of a username?
Something like
webmaster : /var/spool/virtual/webmaster

Courier IMAP would then pick it up, so that I don't need a local server user for this account. Any help appreciated!

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Thu 7 Jul 2005 at 21:46
[ View Steve's Scratchpad | View Weblogs ]

To be honest I'm not sure this is possible.

Although you could rewrite things via procmail instead perhaps?

If it is possible, and you learn how I'd appreciate learning too!

Steve
-- Steve.org.uk

[ Parent | Reply to this comment ]

Posted by Anonymous (62.3.xx.xx) on Fri 8 Jul 2005 at 08:21
I wonder if I could get it to work if I handle the users in a MySQL database. This website somewhat suggests that it could work:
http://www.tty1.net/virtual_domains_en.html

I will give it a try later on.

[ Parent | Reply to this comment ]

Posted by Anonymous (198.54.xx.xx) on Fri 15 Jul 2005 at 13:20
Try This site. A bit outdated but the MYSQL Queries and Exim Config are greate for virtual users. I suggest you leave out the Spamassasin and Amavis Directors and use the clamav scan as SMTP time documented on this site

http://www.xmn-berlin.de/~marte/exim/exim4_mysql_amavis_spamassas in.html

Dale Allan
dale@cybercat.co.za

[ Parent | Reply to this comment ]

Posted by crazeduser (58.81.xx.xx) on Mon 10 Jul 2006 at 17:23
Thanks for a great article and a lot of helpful feedback.

Can someone please comment on the following 2 things:

1) When using maildir directories what ownerships and permissions should the user's root maildir directory and the cur/new/tmp directories be set to? I have this wrong clearly as when I try to view an IMAP folder list in Outlook Express I get a warning "Your IMAP server wishes to alert you to the following: Fatal error: Permission denied"

2) Exim4 presumably should run under Debian-exim user, but what about if using mysql authentication and courier as on the http://www.xmn-berlin.de site above? Right now I think everything is running under root which isn't so good...

I've tried searching for the answers to these questions for over the last hour and it's hard to find a good answer.

thanks a lot,
-Jim

[ Parent | Reply to this comment ]

Posted by Anonymous (62.3.xx.xx) on Sat 30 Jul 2005 at 19:54
I did get it to work with a MySQL database and the help of this website:
http://www.tty1.net/virtual_domains_en.html

I even got courier-imap reading from the same database table.
The only thing I'm having problems (or maybe not) is Exim SMTP. I managed to setup so that users can use "Login" and "Plain" methods which then allows sending mail to other servers. Using no authorisation only allows emailing systems users. I couldn't get it to *require* Login/Plain authorisation. Is that because it is needed to accept incoming emails from other mailservers? Sorry, I'm still learning about how all this works. I just think it might be a security concern as it is easy to find out which users exist on the system and which don't.

[ Parent | Reply to this comment ]

Posted by Anonymous (82.71.xx.xx) on Mon 31 Oct 2005 at 20:44
Yes, it is - you use the appendfile driver, with maildir option set. But you'll need to make sure only a very specific router matches that transport, and nothing else.

[ Parent | Reply to this comment ]

Posted by Anonymous (24.179.xx.xx) on Sun 16 Oct 2005 at 04:48
Have you tried it? That should work fine. You may need to explicitly set user and group under your vdom_aliases section (if you followed this tutorial) to get the permissions correct.

[ Parent | Reply to this comment ]

Posted by Anonymous (84.190.xx.xx) on Wed 13 Jul 2005 at 00:29
Hello!

Will this modification also work with external users? I mean if i have a virtual domain file
"avirtualdomain.com" in /etc/exim4/virtual which has

user: realuser@myrexternaldomain.com

will a mail to user@avirtualdomain.com send to realuser@myexternaldomain.com?

Axel

[ Parent | Reply to this comment ]

Posted by zeb (67.164.xx.xx) on Tue 26 Jul 2005 at 05:56
I can't get it to work. Everything seems to be working, but emails to the virtual hosts gets returned " Bad destination system address."

Right now I'm assuming that the problem lies in the text file in /etc/exim4/virtual for the mapping to the local user.

So let's walk it through. I have a server that has a local domain name of XYZ.net. XYZ.net has a local user named ralph, who can get email at ralph@XYZ.net. ralph also has his own domain name QST.com which is hosted on the XYZ.net server. So ralph wants mail sent to ralph@QST.com to actually be delievered to ralph@XYZ.net.

Here's what I did:

1. Created a text file in /etc/exim4/virtual and named it QST.com

2. In that text file I put the following:

ralph : ralph@localhost

But it doesn't work. All other instructions were followed to the letter, and exim4 restarts without any complaints. Any ideas?

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Tue 26 Jul 2005 at 10:55
[ View Steve's Scratchpad | View Weblogs ]

Did you receive any errors when running update-exim.conf you say restarting exim4 gives no errors, so that's good

Running does running "exim4 -bV" generate any errors?

Finally when you receive the error message what does exim say in the logfiles /var/log/exim4/mainlog and /var/log/exim4/paniclog ?

If you've only made the changes as described then I can't think of anything immediately obvious which could have gone wrong ..

Is localhost resolvable to your DNS ? (I guess it is, just a thought)

Steve
-- Steve.org.uk

[ Parent | Reply to this comment ]

Posted by zeb (67.164.xx.xx) on Tue 26 Jul 2005 at 17:08
I'll answer your questions in order.

update-exim.conf returns the error "command not found"
update-exim4.conf works, no error messages

exim4 -bV generates the following:

Exim version 4.50 #1 built 27-May-2005 08:10:05
Copyright (c) University of Cambridge 2004
Berkeley DB: Sleepycat Software: Berkeley DB 4.2.52: (December 3, 2003)
Support for: iconv() IPv6 PAM Perl GnuTLS Content_Scanning Old_Demime
Lookups: lsearch wildlsearch nwildlsearch iplsearch cdb dbm dbmnz dnsdb dsearch ldap ldapdn ldapm mysql nis nis0 passwd pgsql
Authenticators: cram_md5 cyrus_sasl plaintext spa
Routers: accept dnslookup ipliteral iplookup manualroute queryprogram redirect
Transports: appendfile/maildir/mailstore/mbx autoreply lmtp pipe smtp
Fixed never_users: 0
Configuration file is /var/lib/exim4/config.autogenerated


Nothing from the hosted domain (the virtual host) shows up in any of the logs. Meanwhile all mail to local users gets through. DNS is working for the hosted site, its web page resolves by name, it can be pinged, etc. But mail doesn't even get through far enough to generate a log entry about rejection. It does seem to be a DNS problem. Is there some sort of entry that needs to be made in the bind files?

Your help is appreciated.

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Tue 26 Jul 2005 at 19:23
[ View Steve's Scratchpad | View Weblogs ]

DNS-wise .. the only obvious thing to ask is does the MX entry for the domain point to that machine?

Or is the mail getting sent elsewhere?

Steve
-- Steve.org.uk

[ Parent | Reply to this comment ]

Posted by zeb (67.164.xx.xx) on Tue 26 Jul 2005 at 23:40
That was it. The bind zone file for the virtual needed a little change on one line. Now it works like a charm. Thanks.

Now if I could get SMTP auth (exim4/courier) working. Do you know of any good tutorials or howtos on that topic?

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Tue 26 Jul 2005 at 23:57
[ View Steve's Scratchpad | View Weblogs ]

Cool glad I could help.

As for SMTP auth I don't have anything bookmarked, but I don't recall it being a big job.

Perhaps google can help?

Steve
-- Steve.org.uk

[ Parent | Reply to this comment ]

Posted by zeb (67.164.xx.xx) on Wed 27 Jul 2005 at 07:08
The documentation for SMTP Auth seems to be complete, but I'm having a devil of a time getting it to work.

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Thu 28 Jul 2005 at 22:28
[ View Steve's Scratchpad | View Weblogs ]

I found this page to be useful:

http://www.chrissearle.org/archives/2005/05/19/sendmail-exim4/, perhaps that will help?

Steve
-- Steve.org.uk

[ Parent | Reply to this comment ]

Posted by Migoo (83.248.xx.xx) on Sun 31 Jul 2005 at 14:11
I'm pretty new to the version 4 of exim. Have used 3.x together with Cyrus Imapd. Is there any of you who knows who to extend this to be using Cyrus Imapd + shared folders in Cyrus?

[ Parent | Reply to this comment ]

Posted by dhj (83.166.xx.xx) on Wed 14 Sep 2005 at 09:41
Just a tip for the end of the process. Use this:

tail -f /var/log/exim4/mainlog

to see if your mail is being sent correctly.

[ Parent | Reply to this comment ]

Posted by Anonymous (210.84.xx.xx) on Wed 16 Nov 2005 at 07:49
Wondering if someone can help

I set up everything that was in the instructions but I'm having issues

What I want to do is have two domains on the same box.
Say i have a user called joe and I have created this user account on my Sarge Box.

I now want to set up exim so there is domain blah.com and blah2.com. I did this following the instructions given. I now want user joe to receive mail for both domains however separately. For this example say both these domains reside on a box at home. I then want to receive mail for joe@blah.com, not joe@blah2.com where I have configured a mail client at work. At first the second domain (blah2.com) got rejected cos relaying wasn't allowed so I went into dpkg-reconfigure exim4-config and allowed relaying. However my problem now is that if I send mail to joe@blah.com or joe@blah2.com, I get the mail for both. I only want the mail for the address I send it to. So If I set up a client on a Windows box for joe@blah2.com using the pop3 blah2.com, I only want to receive mail for joe@blah2.com, not also joe@blah.com

Can anyone help?

Cheers

[ Parent | Reply to this comment ]

Posted by redbeard (64.218.xx.xx) on Tue 4 Apr 2006 at 23:04
[ View redbeard's Scratchpad | View Weblogs ]
Rather than setting the domainlist directly, I changed it via dpkg-reconfigure. If you set the Other Hostnames setting to 'dsearch;/etc/exim4/virtual' you get the same results.

Michael

[ Parent | Reply to this comment ]

Posted by Anonymous (212.159.xx.xx) on Tue 27 Jun 2006 at 09:42
Thank for writing this, most useful.

Just in case others were wondering, you can also follow the above steps with exim4-daemon-light to setup virtual domains. exim4-daemon-heavy is only required in the above steps so virus scanning can also be added at smtp time.

Nick

[ Parent | Reply to this comment ]

Posted by Anonymous (216.210.xx.xx) on Wed 1 Nov 2006 at 17:47
Steve,
I followed the directions of your exim4/virt domain article here:
http://www.debian-administration.org/articles/140

And everything works fine for the virtual domains, but the actual domain ceases to work. The machine this is running on has always been ‘mail.midstateconstruction.com’ handling mail for the domain ‘midstateconstruction.com’ until I added three other virtual domains just now. /etc/exim4/virtual has three diff domains: rjnconstructioninc.com, midstatecommercial.com and midstateresidential.com.

If I touch a 4th file: midstateconstruction.com (the original domain, and the ns for this ip) can I add a line like ‘* : *@localhost’ ? That way whenever I add or del a user, I don’t have to add a line for them within the virt domain ‘midstateconstruction.com’ ?

Only 5 diff users will have email address with the 3 new virtual domains, but 50 users have and have always had addresses with the original domain: midstateconstruction.com

Thanks!
-eric

[ Parent | Reply to this comment ]

Posted by Anonymous (216.210.xx.xx) on Wed 1 Nov 2006 at 18:12
My solution included:

While I was getting desperate I went for broke and tried a variety of things.
What seemed to work was modifying my local-domains to include MAIN_LOCAL_DOMAINS

.ifndef MAIN_LOCAL_DOMAINS
MAIN_LOCAL_DOMAINS = DEBCONFlocal_domainsDEBCONF
.endif
domainlist local_domains = @:localhost:dsearch;/etc/exim4/virtual:MAIN_LOCAL_DOMAINS

I also removed the “no_more” from the router (I use single file exim4.conf) and I touched midstateconstruction.com within /etc/exim4/virtual

Thanks for the tutorial!
-e

[ Parent | Reply to this comment ]

Posted by Anonymous (24.108.xx.xx) on Thu 23 Nov 2006 at 10:15
Can I use local user names with the @ symbol in them?

eve : eve@example.org@localhost

where eve@example.org is the username on the machine
as well as the e-mail address for the user?

[ Parent | Reply to this comment ]

Posted by Steve (80.68.xx.xx) on Thu 23 Nov 2006 at 11:23
[ View Steve's Scratchpad | View Weblogs ]

Try it and see?

Either way local usernames with "@" symbols in them are going to cause you problems sooner or later ..

Steve

[ Parent | Reply to this comment ]

Posted by bobibleyboo (64.180.xx.xx) on Fri 24 Nov 2006 at 16:55
It will not work with user names containing the @ symbol
as the config param uses this as the delimiter between the
user name and the domain name.

[ Parent | Reply to this comment ]

Posted by Anonymous (80.130.xx.xx) on Wed 14 Dec 2011 at 21:32
No, a local part with "@" in it won't work. The default exim4 config (and debian's) denies sending to mail addresses, where the local part starts with a dot or contains other characters usually not used in email addresses.

See the ACL section of the config file.

You could have exim accept these email adresses, but YMMV.

[ Parent | Reply to this comment ]

Posted by Anonymous (24.108.xx.xx) on Thu 23 Nov 2006 at 12:16
Using this setup how would you
have more then one account recieve a copy of an e-mail
sue : sue@localhost : joe@localhost ?
would that work?

[ Parent | Reply to this comment ]

Posted by Anonymous (204.174.xx.xx) on Fri 1 Dec 2006 at 04:29
What he proposes does not work But I am having the same problem
Does anybody know how you would do this?

[ Parent | Reply to this comment ]

Posted by butch (84.41.xx.xx) on Fri 15 Dec 2006 at 18:33
This works for me:

sharedaddress : user1,user2
user1 : user1@localhost
user2 : user2@localhost

[ Parent | Reply to this comment ]

Posted by grummund (82.152.xx.xx) on Mon 18 Dec 2006 at 00:08
Hi,

thanks for a great article. I've been using the recipe described in the article for multiple virtual domains with exim4 for several months now without a hitch. I wish Debian exim came ready boxed with this or a similar setup, but still it's easy enough to add.

I have a backup-mx which will accept mail if the primary mx is down and then forward it when the primary mx comes back up. The problem is that by default it will accept mail for *any* user for all the domains that it relays.

Since spam is often to random recipients, and usually has forged sender address, this causes much back-scatter when the forwarded mail finally hits the primary mx. (The primary mx rejects it due to invalid user and then the backup mx sends out a bounce to the forged sender address.)

I tried using recipient callouts, which work okay, and solve the back-scatter problem while the primary-mx is up. However it's a sub-optimal solution because it increases the load on both servers and of course it relies on the primary-mx being up!

So... What I'm wondering is how the solution described in this article could be scaled across one or more backup-mx machines?

Ideally using identical, or nearly identical, config files to manage the user list between primary-mx and backup-mx's. Something perhaps as simple as rsync'ing the /etc/exim/virtual directory across from the primary to backup machines.

[ Parent | Reply to this comment ]

Posted by curt (69.208.xx.xx) on Wed 10 Jan 2007 at 20:53
Would it also be proper to add @:localhost:dsearch;/etc/exim4/virtual to "domainlist relay_to_domains =" in /etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs ?
I know the answer is probably in the manual but would doing the above open up exim4 for spammers or would the relay_to_domains be authenticated users only?
Would setting the permissions to 644 of /etc/exim4/virtual and the files therein be correct?

Thanks for all the articles you write Steve, I have used many... As for this one particular, it has saved me from sendmail hell. What was I thinking?

[ Parent | Reply to this comment ]

Posted by Steve (62.30.xx.xx) on Wed 10 Jan 2007 at 22:11
[ View Steve's Scratchpad | View Weblogs ]

In reverse order .. Permissions of 644 would be fine for the virtual files. So long as they are readable to the exim4 process all will work. You could allow them to be writable by a local user who was in charge of the domains, but I'm not sure if that is such a good idea in practise - for that level of control perhaps a database-backend and a simple front-end application?

As for adding the search elsewhere - I don't think that is a good idea:

  • Authenticated users will be able to relay anywhere anyway - so long as they are authenticated
  • Adding domains to that list will allow anybody connecting to send mail to those domains, relaying spam essentially, since the senders will not need to be authenticated.

PS. Thanks :)

Steve

[ Parent | Reply to this comment ]

Posted by dhj (82.71.xx.xx) on Tue 27 Mar 2007 at 14:25
We just upgraded our server to the version of exim4 in Debian testing today, and it broke the configuration suggested on this page (which was working for a long time with no problems at all - thanks Steve!)

The problem is that the dsearch feature appears to have been removed from recent versions of exim4, or at least the Debian package of it. See under version 4.63-7 here:

http://packages.debian.org/changelogs/pool/main/e/exim4/exim4_4.6 3-17/changelog

* Special-case "dsearch;" constructs in dc_other_hostnames, no
longer supported. Adapt documentation accordingly.

I fixed this in the meantime by adding a static list of domain names in place of the 'dsearch;/etc/exim4/virtual' line in both places. It's not as elegant as Steve's method though.

Cheers!

Daniel

[ Parent | Reply to this comment ]

Posted by Steve (62.30.xx.xx) on Sun 1 Apr 2007 at 11:55
[ View Steve's Scratchpad | View Weblogs ]

Good to know, thanks for the update.

I guess the general purpose solution is to generate that list automagically from the virtual domain filenames..

Steve

[ Parent | Reply to this comment ]

Posted by Tobus (203.129.xx.xx) on Thu 12 Apr 2007 at 18:05
This is pretty easy to fix....

Firstly, change your update-exim4.conf.conf to use "dc_other_hostnames=host1;host2;dsearch=/etc/exim4/virtual&q uot;

Note the "=" instead of the usual ";" after dsearch - (you can use any character here instead of an "=" - so long as you use the same character where I've got the "=" in the modified sed line below)

Then, change the update script:

/usr/sbin/update-exim4.conf, line 127

change:
sed -e 'sA[;: ]*$AA' -e 'sA *AA' -e 'sA;A:Ag' )"
to:
sed -e 'sA[;: ]*$AA' -e 'sA *AA' -e 'sA;A:Ag' -e 'sA=A;Ag' )"

(in english, that's get it to replace "=" with ";" after it does all the other replacements)

[ Parent | Reply to this comment ]

Posted by Anonymous (76.209.xx.xx) on Thu 24 May 2007 at 20:05
I proposed an approach that works on current (and old) exim4 Debian packages. It is in bug 418910.

In short, if you used to enter

pimlott.net:dsearch;/etc/exim4/virtual
in dc_other_hostnames (ie, the question "Other destinations for which mail is accepted:), then you should instead add the following line to exim4.conf.localmacros:
MAIN_LOCAL_DOMAINS = @:localhost:pimlott.net:dsearch;/etc/exim4/virtual

[ Parent | Reply to this comment ]

Posted by Anonymous (87.210.xx.xx) on Mon 21 Jan 2008 at 10:57
Frozen message.

It does not work.

i removed the entry's in the normal aliases.

any suggestions

Erik

[ Parent | Reply to this comment ]

Posted by Anonymous (87.210.xx.xx) on Mon 21 Jan 2008 at 12:03
http://www.debuntu.org/2006/05/17/52-how-to-exim4-virtual-host-on -debian-etch


I used above link for the solution.

now it works !

Even thank you for learning a lot about exim4 vdomains.

Erik.
http://www.coorengel.eu

[ Parent | Reply to this comment ]

Posted by Anonymous (82.35.xx.xx) on Sat 14 Feb 2009 at 19:06
Thanks. Exactly what we needed 3 years ahead of this great article :)

[ Parent | Reply to this comment ]

Posted by Thomas1234 (82.215.xx.xx) on Mon 30 Nov 2009 at 09:15
My problem is that 1 user can't receive an e-mail multiple time.

My configuration:
user1@host.ext: vmail
user2@host.ext: vmail
user3@host.ext: vmail

When there's 1 e-mail for user1@host.ext,user2@host.ext,user3@host.ext; this e-mail will only be delivered once.

In my configuration procmail will deliver the e-mail for the vmail-user to the different Maildir.

Exim will only deliver 1 mail because it removes duplicate adresses. See: 22.7 Duplicate addresses at http://www.exim.org/exim-html-4.50/d...l/spec_22.html

But how can i change this, so exim won't remove it?

Thomas Lenting

[ Parent | Reply to this comment ]

Sign In

Username:

Password:

[Register|Advanced]

 

Flattr

 

Current Poll

What do you use for configuration management?








( 339 votes ~ 1 comments )

 

 

Related Links