+======================================================================+
| (Please see instructions in README.exim_v4. The setup described here |
| is not recommended with amavisd-new + Exim v4)                       |
+======================================================================+



See also:
  http://ente.limmat.ch/linux/exim_v3_-_amavisd-new.html
  http://bugs.debian.org/213422


How To Use AMaViS With exim
***************************


Exim 3.x
********

Scanning incoming mail only
===========================

First of all, create the group "amavis" and the user "amavis", which
is in this group. Add the user amavis to your trusted users, so in the
MAIN CONFIGURATION SETTINGS add the following line

trusted_users = amavis

(or, if this line already exists simply add amavis, separated with a
colon).

In the TRANSPORT CONFIGURATION, add the following:

amavis:
   driver = smtp
   port = 10024
   hosts = 127.0.0.1
   allow_localhost

Here below is an old variant of a transport which uses a pipe to a helper
program amavis(.c). As feeding to amavisd-new with SMTP is easier and
possibly faster, the pipe via helper setup is not recommended - it is
included here for the curious:

# amavis:
#   driver = pipe
#   command = "/usr/sbin/amavis <${sender_address}> ${pipe_addresses}"
#   prefix =
#   suffix =
#   check_string =
#   escape_string =
# # for debugging change return_output to true
#   return_output = false
#   return_path_add = false
#   user = amavis
#   group = amavis
#   path = "/bin:/sbin:/usr/bin:/usr/sbin"
#   current_directory = "/var/amavis"

At the *beginning* of the DIRECTORS CONFIGURATION, add the following:

amavis_director:
  condition = "${if eq {$received_protocol}{scanned-ok} {0}{1}}"
  driver = smartuser
  transport = amavis
  # verify must be set to false, to avoid troubles with receiver and/or
  # sender verify
  verify = false


NOTE: Please keep in mind that the ORDER matters!

Scanning incoming/outgoing and relayed mail
===========================================

Scanning of outgoing mail is also possible (based on a contribution
by John Burnham).

Additionally to the steps mentioned at the "Scanning incoming mail only"
section, do the following:

At the *beginning* of the ROUTERS CONFIGURATION, add the following

amavis_router:
  condition = "${if eq {$received_protocol}{scanned-ok} {0}{1}}"
  driver = domainlist
  route_list = "*"
  transport = amavis
  # verify must be set to false, to avoid troubles with receiver and/or
  # sender verify
  verify = false



The configure script should be called with the option
--enable-exim. Well, it is enabled by default if the MTA qmail is not
installed on the system.

NOTE: if the MTA qmail is installed on your system, too, you *MUST*
add --disable-qmail

NOTE: do not forget to set up an (eMail) alias for "amavis" to a real
user account. If you used --with-notifyreceivers, and a user sends a
mail to an non-existent remote user, the bounce message from the
remote MTA will be send to pseudo-user amavis.

Note: If you want to add a "X-Virus-Scanned" header you can do this in
your exim configuration, too. Use the headers_add option in the
amavis TRANSPORT CONFIGURATION, i.e.  headers_add =
"X-Virus-Scanned: by AMaViS (<a href="http://amavis.org/">http://amavis.org/</a>)"


Exim 4.x
********

+======================================================================+
| (Please see instructions in README.exim_v4. The setup described here |
| is not recommended with amavisd-new + Exim v4)                       |
+======================================================================+


The setup is very similar to the Exim 3.x one, so you should read
this section first.


# trusted users
trusted_users = amavis


Routers configuration:
# in routers:

amavis_router:
  condition = "${if eq {$received_protocol}{scanned-ok} {0}{1}}"
  driver = accept
  transport = amavis
  # verify must be set to false, to avoid troubles with receiver and/or
  # sender verify
  verify = false


Transport configuration:

After the

remote_smtp:
  driver = smtp

entry, add the following entry

amavis:
   driver = smtp
   port = 10024
   hosts = 127.0.0.1
   allow_localhost

Or the old variant via pipe to amavis(.c) helper program (not recommended):

# amavis:
#   driver = pipe
#   command = "/usr/sbin/amavis <${sender_address}> ${pipe_addresses}"
# # for debugging change return_output to true
#   return_output = false
#   return_path_add = false
#   user = amavis
#   group = amavis
#   path = "/bin:/sbin:/usr/bin:/usr/sbin"
#   current_directory = "/var/amavis"


(based on a mail to exim-users by Niels Dettenbach)


AMaViS via exim system filter
*****************************

This setup has not been tested by the AMaViS team yet. Feedback on this
is very welcome! Based on a mail from Dariusz Sznajder to the amavis-
user mailing list (<a href="http://marc.theaimsgroup.com/?l=amavis-user">http://marc.theaimsgroup.com/?l=amavis-user</a>&amp;m=102861263206738&amp;w=2)

In exim/configure I have:
	[...]
	system_filter = /etc/exim.filter
	system_filter_pipe_transport = amavis_pipe

	[...]
	amavis_pipe:
	  driver = pipe
	  user = amavis
	  return_output
	  headers_add = ${if def:authenticated_id {X-Authenticated-Sender: $authenticated_id}{}}

	[...]

/etc/exim.filter
	# Exim filter

	# drop out error messages here
	if $received_protocol is "scanned-ok"
	then
	    finish
	endif

	pipe "/usr/sbin/amavis \"$sender_address\" \"$recipients\""


AMaViS has to be configured as ./configure --enable-exim



FAQ
---

Q: Whenever I am receiving many mails in large batches (i.e. via
UUCP or fetchmail), the system load on the machine on which AMaViS
runs climbs to a level that renders the machine virtually unusable.
How do I prevent such behaviour?

A: The reason for the high load is that one AMaViS process (and in
turn AMaViS' children processes) are started for every message that is
received. The obvious solution is to limit the number of AMaViS
processes that are started simultaniously.

AMaViS does not currently support this itself, but every sensible MTA
does. Moreover, it makes sense to limit the number of messages that an
MTA can deliver at one time, to prevent mail server death by spamming.

For Exim, the configuration keywords to look for are deliver_load_max,
deliver_queue_load_max, and queue_only_load which control whether
mails are delivered (read: passed to AMaViS) or queued only under high
load. More detailed information can be found in the Exim
Specification.


Credits
-------
Philip Hazel, Marc Haber, John Burnham, Jeffrey C. Ollie, Hilko Bengen,
Niels Dettenbach, Dariusz Sznajder


TODO
----

* whatever you whish to add here :-)

Author
------
Rainer Link
eMail: <a href="mailto:Rainer.Link@suse.de">Rainer.Link@suse.de</a>
WWW: <a href="http://rainer.w3.to">http://rainer.w3.to</a>

Please send bug reports, questions, suggestions and more directly to
the author. Thanks :-)

Updated by Mark Martinec, based on suggestion
in http://bugs.debian.org/213422 from Enrico
