# [Exim] Inbound SMTP mails are delivered more than once

## cfvr

Hi, I'm fairly new to Gentoo, (and Linux for that matter) so I hope I can provide enough info to get some assistance with an annoying Exim problem. I have installed a Gentoo box to function as a SMTP gateway in my Windows/Exchange network. The problem is that some inbound emails are delivered more that once by Exim. People get for example every two hours (not exactly) the same email, over and over again.

Here's the network setup for email:

Internet ------ Firewall --- port 25 open to the internet----- Gentoo --------- Exchange server ----------- Outlook

The Gentoo box is running:

Exim 4.43-r2

Spamassassin 3.0.2

Clamav 0.82R1

Here are some headers of identically delivered emails: 

```

Received: from gentoobox.mydomain.local (10.0.0.9 [10.0.0.9]) by exchangebox.mydomain.local with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72)

   id DS1HD12L; Fri, 18 Feb 2005 01:25:57 +0100

Received: from smtp3.euronet.nl ([194.134.35.173])

   by gentoobox.mydomain.local with esmtp (Exim 4.43)

   id 1D1vra-00030B-Fo

   for recipient@mydomain.tld; Fri, 18 Feb 2005 01:25:41 +0100

Received: from euronet.nl (pm-c-7b45.mxs.adsl.euronet.nl [62.234.155.69])

   by smtp3.euronet.nl (Postfix) with ESMTP id 508C13A1BD

   for <recipient@mydomain.tld>; Thu, 17 Feb 2005 12:11:42 +0100 (MET)

Date: Thu, 17 Feb 2005 12:11:40 +0100

Mime-Version: 1.0 (Apple Message framework v553)

Content-Type: multipart/mixed; boundary=Apple-Mail-3--665001349

Subject: test filmpje

From: b612 <sender@hisdomain.tld>

To: Gea de Jong <recipient@mydomain.tld>

Message-Id: <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl>

X-Mailer: Apple Mail (2.553)

===============================

Received: from gentoobox.mydomain.local (10.0.0.9 [10.0.0.9]) by exchangebox.mydomain.local with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72)

   id DS1HD1H9; Fri, 18 Feb 2005 00:03:45 +0100

Received: from smtp3.euronet.nl ([194.134.35.173])

   by gentoobox.mydomain.local with esmtp (Exim 4.43)

   id 1D1uYw-0001f3-Er

   for recipient@mydomain.tld; Fri, 18 Feb 2005 00:03:29 +0100

Received: from euronet.nl (pm-c-7b45.mxs.adsl.euronet.nl [62.234.155.69])

   by smtp3.euronet.nl (Postfix) with ESMTP id 508C13A1BD

   for <recipient@mydomain.tld>; Thu, 17 Feb 2005 12:11:42 +0100 (MET)

Date: Thu, 17 Feb 2005 12:11:40 +0100

Mime-Version: 1.0 (Apple Message framework v553)

Content-Type: multipart/mixed; boundary=Apple-Mail-3--665001349

Subject: test filmpje

From: b612 <sender@hisdomain.tld>

To: Gea de Jong <recipient@mydomain.tld>

Message-Id: <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl>

X-Mailer: Apple Mail (2.553)

===============================

Received: from gentoobox.mydomain.local (10.0.0.9 [10.0.0.9]) by exchangebox.mydomain.local with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72)

   id DS1HD1GH; Thu, 17 Feb 2005 22:48:03 +0100

Received: from smtp3.euronet.nl ([194.134.35.173])

   by gentoobox.mydomain.local with esmtp (Exim 4.43)

   id 1D1tGK-0000Jl-RZ

   for recipient@mydomain.tld; Thu, 17 Feb 2005 22:47:35 +0100

Received: from euronet.nl (pm-c-7b45.mxs.adsl.euronet.nl [62.234.155.69])

   by smtp3.euronet.nl (Postfix) with ESMTP id 508C13A1BD

   for <recipient@mydomain.tld>; Thu, 17 Feb 2005 12:11:42 +0100 (MET)

Date: Thu, 17 Feb 2005 12:11:40 +0100

Mime-Version: 1.0 (Apple Message framework v553)

Content-Type: multipart/mixed; boundary=Apple-Mail-3--665001349

Subject: test filmpje

From: b612 <sender@hisdomain.tld>

To: Gea de Jong <recipient@mydomain.tld>

Message-Id: <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl>

X-Mailer: Apple Mail (2.553)

```

As you can see the Message ID that the Gentoo box assigns to the message is different for each email, but it stays the same for the sending SMTP server ( Message-Id: <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl> )

In my firewall logs there are no entries of SMTP traffic from smtp3.euronet.nl ([194.134.35.173], only for the first email that was received. That puts Exim as the prime suspect for this problem.

For the above example emails I found this in the exim_main.log:

```

2005-02-18 00:03:29 1D1uYw-0001f3-Er <= sender@hisdomain.tld H=smtp3.euronet.nl [194.134.35.173] P=esmtp S=4317148 id=B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl

2005-02-18 00:03:36 1D1uYw-0001f3-Er => recipient@mydomain.tld R=send_to_rf T=remote_smtp H=exchangebox.mydomain.local [10.0.0.2]

2005-02-18 00:03:36 1D1uYw-0001f3-Er Completed

2005-02-18 01:25:41 1D1vra-00030B-Fo <= sender@hisdomain.tld H=smtp3.euronet.nl [194.134.35.173] P=esmtp S=4317148 id=B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl

2005-02-18 01:25:47 1D1vra-00030B-Fo => recipient@mydomain.tld R=send_to_rf T=remote_smtp H=exchangebox.mydomain.local [10.0.0.2]

2005-02-18 01:25:47 1D1vra-00030B-Fo Completed

2005-02-17 22:47:36 1D1tGK-0000Jl-RZ <= sender@hisdomain.tld H=smtp3.euronet.nl [194.134.35.173] P=esmtp S=4317148 id=B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl

2005-02-17 22:47:57 1D1tGK-0000Jl-RZ => recipient@mydomain.tld R=send_to_rf T=remote_smtp H=exchangebox.mydomain.local [10.0.0.2]

2005-02-17 22:47:57 1D1tGK-0000Jl-RZ Completed

```

Except for the Message ID staying the same, nothing fishy I suppose. 

When I grep the Message ID from /var/log/messages I get this:

```

Feb 17 17:01:00 ASDRF8 spamd[15720]: checking message <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl> for nobody:65534.

Feb 17 17:01:03 ASDRF8 spamd[15720]: result: .  0 - FORGED_RCVD_HELO,FROM_ENDS_IN_NUMS scantime=5.6,size=4316228,mid=<B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl>,autolearn=disabled

Feb 17 18:38:52 ASDRF8 spamd[31480]: checking message <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl> for nobody:65534.

Feb 17 18:40:16 ASDRF8 spamd[31480]: result: .  0 - FORGED_RCVD_HELO,FROM_ENDS_IN_NUMS scantime=880.1,size=4316228,mid=<B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl>,autolearn=disabled

Feb 17 19:50:13 ASDRF8 spamd[8132]: checking message <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl> for nobody:65534.

Feb 17 19:52:05 ASDRF8 spamd[8132]: result: .  0 - FORGED_RCVD_HELO,FROM_ENDS_IN_NUMS scantime=210.9,size=4316228,mid=<B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl>,autolearn=disabled

Feb 17 22:42:17 ASDRF8 spamd[29930]: checking message <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl> for nobody:65534.

Feb 17 22:47:30 ASDRF8 spamd[29930]: result: .  0 - FORGED_RCVD_HELO,FROM_ENDS_IN_NUMS scantime=779.4,size=4316228,mid=<B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl>,autolearn=disabled

Feb 18 00:02:04 ASDRF8 spamd[8132]: checking message <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl> for nobody:65534.

Feb 18 00:03:29 ASDRF8 spamd[8132]: result: .  0 - FORGED_RCVD_HELO,FROM_ENDS_IN_NUMS scantime=306.9,size=4316228,mid=<B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl>,autolearn=disabled

Feb 18 01:23:05 ASDRF8 spamd[4332]: checking message <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl> for nobody:65534.

Feb 18 01:25:41 ASDRF8 spamd[4332]: result: .  0 - FORGED_RCVD_HELO,FROM_ENDS_IN_NUMS scantime=224.1,size=4316228,mid=<B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl>,autolearn=disabled

Feb 18 02:47:19 ASDRF8 spamd[8132]: checking message <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl> for nobody:65534.

Feb 18 02:47:55 ASDRF8 spamd[8132]: result: .  0 - FORGED_RCVD_HELO,FROM_ENDS_IN_NUMS scantime=218.3,size=4316228,mid=<B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl>,autolearn=disabled

Feb 18 04:11:09 ASDRF8 spamd[31480]: checking message <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl> for nobody:65534.

Feb 18 04:13:40 ASDRF8 spamd[31480]: result: .  0 - FORGED_RCVD_HELO,FROM_ENDS_IN_NUMS scantime=344.3,size=4316228,mid=<B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl>,autolearn=disabled

Feb 18 05:33:19 ASDRF8 spamd[31480]: checking message <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl> for nobody:65534.

Feb 18 05:36:00 ASDRF8 spamd[31480]: result: .  0 - FORGED_RCVD_HELO,FROM_ENDS_IN_NUMS scantime=298.0,size=4316228,mid=<B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl>,autolearn=disabled

Feb 18 08:24:17 ASDRF8 spamd[4030]: checking message <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl> for nobody:65534.

Feb 18 08:24:21 ASDRF8 spamd[4030]: result: .  0 - FORGED_RCVD_HELO,FROM_ENDS_IN_NUMS scantime=5.7,size=4316228,mid=<B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl>,autolearn=disabled

Feb 18 09:40:58 ASDRF8 spamd[5369]: checking message <B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl> for nobody:65534.

Feb 18 09:41:01 ASDRF8 spamd[5369]: result: .  0 - FORGED_RCVD_HELO,FROM_ENDS_IN_NUMS scantime=6.1,size=4316228,mid=<B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl>,autolearn=disabled

```

It looks like the spamd process is taking a long time to scan the email, but not all the time.

Can it be a time-out from the spamd process that makes the email get processed by Exim several times?Last edited by cfvr on Fri Feb 18, 2005 5:09 pm; edited 1 time in total

----------

## adaptr

That depends; is SA running as an Exim transport or through an MDA such as procmail ?

If it is integrated then Exim may get confused by this, but only if Exim re-receives the mail after SA has scanned it.

Most SA installations use procmail or another MDA to pass off the mail to SA, so it never gets re-inserted into the MTA's message stream.

I would try that - set up SA to run from a users' .procmailrc so you can isolate stuff.

Apart from that, your Router looks homebuilt (send_to_rf); it is much more likely that something is wrong with that.

----------

## cfvr

I followed the tutorial found on this board for setting up spamassassin clamav and Exim:

https://forums.gentoo.org/viewtopic-t-83500-highlight-exim+clamav+spamassassin.html

So I hope you can tell me in what way spamassassin is used. I have no clue to tell you the truth  :Neutral: 

I just didn't emerge courier-imapd, because I only use the Exim MTA as an email gateway. I have two internal Exchange servers, one handling email for mydomain.tld (renamed of course) and the other handling email for subdomain.mydomain.tld.

Modified exim.conf:

```

######################################################################

#                  Runtime configuration file for Exim               #

######################################################################

# This is a default configuration file which will operate correctly in

# uncomplicated installations. Please see the manual for a complete list

# of all the runtime configuration options that can be included in a

# configuration file. There are many more than are mentioned here. The

# manual is in the file doc/spec.txt in the Exim distribution as a plain

# ASCII file. Other formats (PostScript, Texinfo, HTML, PDF) are available

# from the Exim ftp sites. The manual is also online at the Exim web sites.

# This file is divided into several parts, all but the first of which are

# headed by a line starting with the word "begin". Only those parts that

# are required need to be present. Blank lines, and lines starting with #

# are ignored.

########### IMPORTANT ########## IMPORTANT ########### IMPORTANT ###########

#                                                                          #

# Whenever you change Exim's configuration file, you *must* remember to    #

# HUP the Exim daemon, because it will not pick up the new configuration   #

# until you do. However, any other Exim processes that are started, for    #

# example, a process started by an MUA in order to send a message, will    #

# see the new configuration as soon as it is in place.                     #

#                                                                          #

# You do not need to HUP the daemon for changes in auxiliary files that    #

# are referenced from this file. They are read every time they are used.   #

#                                                                          #

# It is usually a good idea to test a new configuration for syntactic      #

# correctness before installing it (for example, by running the command    #

# "exim -C /config/file.new -bV").                                         #

#                                                                          #

########### IMPORTANT ########## IMPORTANT ########### IMPORTANT ###########

######################################################################

#                    MAIN CONFIGURATION SETTINGS                     #

######################################################################

# Specify your host's canonical name here. This should normally be the fully

# qualified "official" name of your host. If this option is not set, the

# uname() function is called to obtain the name. In many cases this does

# the right thing and you need not set anything explicitly.

# primary_hostname =

# The next three settings create two lists of domains and one list of hosts.

# These lists are referred to later in this configuration using the syntax

# +local_domains, +relay_to_domains, and +relay_from_hosts, respectively. They

# are all colon-separated lists:

domainlist local_domains = @

domainlist relay_to_rf = mydomain.tld : my2nddomain.tld

domainlist relay_to_gs = subdomain.mydomain.tld

hostlist   relay_from_hosts = 127.0.0.1 : 10.0.0.0/24 : 10.10.1.0/24

# Most straightforward access control requirements can be obtained by

# appropriate settings of the above options. In more complicated situations, you

# may need to modify the Access Control List (ACL) which appears later in this

# file.

# The first setting specifies your local domains, for example:

#

#   domainlist local_domains = my.first.domain : my.second.domain

#

# You can use "@" to mean "the name of the local host", as in the default

# setting above. This is the name that is specified by primary_hostname,

# as specified above (or defaulted). If you do not want to do any local

# deliveries, remove the "@" from the setting above. If you want to accept mail

# addressed to your host's literal IP address, for example, mail addressed to

# "user@[192.168.23.44]", you can add "@[]" as an item in the local domains

# list. You also need to uncomment "allow_domain_literals" below. This is not

# recommended for today's Internet.

# The second setting specifies domains for which your host is an incoming relay.

# If you are not doing any relaying, you should leave the list empty. However,

# if your host is an MX backup or gateway of some kind for some domains, you

# must set relay_to_domains to match those domains. For example:

#

# domainlist relay_to_domains = *.myco.com : my.friend.org

#

# This will allow any host to relay through your host to those domains.

# See the section of the manual entitled "Control of relaying" for more

# information.

# The third setting specifies hosts that can use your host as an outgoing relay

# to any other host on the Internet. Such a setting commonly refers to a

# complete local network as well as the localhost. For example:

#

# hostlist relay_from_hosts = 127.0.0.1 : 192.168.0.0/16

#

# The "/16" is a bit mask (CIDR notation), not a number of hosts. Note that you

# have to include 127.0.0.1 if you want to allow processes on your host to send

# SMTP mail by using the loopback address. A number of MUAs use this method of

# sending mail.

# All three of these lists may contain many different kinds of item, including

# wildcarded names, regular expressions, and file lookups. See the reference

# manual for details. The lists above are used in the access control list for

# incoming messages. The name of this ACL is defined here:

acl_smtp_rcpt = acl_check_rcpt

# You should not change that setting until you understand how ACLs work.

# The following ACL entries are used if you want to do content scanning with

# the exiscan-acl patch. When you uncomment one of these lines, you must also

# review the respective entries in the ACL section further below.

acl_smtp_mime = acl_check_mime

acl_smtp_data = acl_check_content

# This configuration variable defines the virus scanner that is used with

# the 'malware' ACL condition of the exiscan acl-patch. If you do not use

# virus scanning, leave it commented. Please read doc/exiscan-acl-readme.txt

# for a list of supported scanners.

# av_scanner = sophie:/var/run/sophie

av_scanner = clamd:/tmp/clamd

# The following setting is only needed if you use the 'spam' ACL condition

# of the exiscan-acl patch. It specifies on which host and port the SpamAssassin

# "spamd" daemon is listening. If you do not use this condition, or you use

# the default of "127.0.0.1 783", you can omit this option.

# spamd_address = 127.0.0.1 783

# Specify the domain you want to be added to all unqualified addresses

# here. An unqualified address is one that does not contain an "@" character

# followed by a domain. For example, "caesar@rome.example" is a fully qualified

# address, but the string "caesar" (i.e. just a login name) is an unqualified

# email address. Unqualified addresses are accepted only from local callers by

# default. See the recipient_unqualified_hosts option if you want to permit

# unqualified addresses from remote sources. If this option is not set, the

# primary_hostname value is used for qualification.

# qualify_domain =

# If you want unqualified recipient addresses to be qualified with a different

# domain to unqualified sender addresses, specify the recipient domain here.

# If this option is not set, the qualify_domain value is used.

# qualify_recipient =

# The following line must be uncommented if you want Exim to recognize

# addresses of the form "user@[10.11.12.13]" that is, with a "domain literal"

# (an IP address) instead of a named domain. The RFCs still require this form,

# but it makes little sense to permit mail to be sent to specific hosts by

# their IP address in the modern Internet. This ancient format has been used

# by those seeking to abuse hosts by using them for unwanted relaying. If you

# really do want to support domain literals, uncomment the following line, and

# see also the "domain_literal" router below.

# allow_domain_literals

# No deliveries will ever be run under the uids of these users (a colon-

# separated list). An attempt to do so causes a panic error to be logged, and

# the delivery to be deferred. This is a paranoic safety catch. There is an

# even stronger safety catch in the form of the FIXED_NEVER_USERS setting

# in the configuration for building Exim. The list of users that it specifies

# is built into the binary, and cannot be changed. The option below just adds

# additional users to the list. The default for FIXED_NEVER_USERS is "root",

# but just to be absolutely sure, the default here is also "root".

# Note that the default setting means you cannot deliver mail addressed to root

# as if it were a normal user. This isn't usually a problem, as most sites have

# an alias for root that redirects such mail to a human administrator.

never_users = root

# The setting below causes Exim to do a reverse DNS lookup on all incoming

# IP calls, in order to get the true host name. If you feel this is too

# expensive, you can specify the networks for which a lookup is done, or

# remove the setting entirely.

# Collin: geen lookups

# host_lookup = *

# The settings below, which are actually the same as the defaults in the

# code, cause Exim to make RFC 1413 (ident) callbacks for all incoming SMTP

# calls. You can limit the hosts to which these calls are made, and/or change

# the timeout that is used. If you set the timeout to zero, all RFC 1413 calls

# are disabled. RFC 1413 calls are cheap and can provide useful information

# for tracing problem messages, but some hosts and firewalls have problems

# with them. This can result in a timeout instead of an immediate refused

# connection, leading to delays on starting up an SMTP session.

# Collin: test vanwege dubbele Emails

# rfc1413_hosts = *

# rfc1413_query_timeout = 30s

# By default, Exim expects all envelope addresses to be fully qualified, that

# is, they must contain both a local part and a domain. If you want to accept

# unqualified addresses (just a local part) from certain hosts, you can specify

# these hosts by setting one or both of

#

# sender_unqualified_hosts =

# recipient_unqualified_hosts =

#

# to control sender and recipient addresses, respectively. When this is done,

# unqualified addresses are qualified using the settings of qualify_domain

# and/or qualify_recipient (see above).

# If you want Exim to support the "percent hack" for certain domains,

# uncomment the following line and provide a list of domains. The "percent

# hack" is the feature by which mail addressed to x%y@z (where z is one of

# the domains listed) is locally rerouted to x@y and sent on. If z is not one

# of the "percent hack" domains, x%y is treated as an ordinary local part. This

# hack is rarely needed nowadays; you should not enable it unless you are sure

# that you really need it.

#

# percent_hack_domains =

#

# As well as setting this option you will also need to remove the test

# for local parts containing % in the ACL definition below.

# When Exim can neither deliver a message nor return it to sender, it "freezes"

# the delivery error message (aka "bounce message"). There are also other

# circumstances in which messages get frozen. They will stay on the queue for

# ever unless one of the following options is set.

# This option unfreezes frozen bounce messages after two days, tries

# once more to deliver them, and ignores any delivery failures.

ignore_bounce_errors_after = 2d

# This option cancels (removes) frozen messages that are older than a week.

timeout_frozen_after = 7d

######################################################################

#                       ACL CONFIGURATION                            #

#         Specifies access control lists for incoming SMTP mail      #

######################################################################

begin acl

# This access control list is used for every RCPT command in an incoming

# SMTP message. The tests are run in order until the address is either

# accepted or denied.

acl_check_rcpt:

  # Accept if the source is local SMTP (i.e. not over TCP/IP). We do this by

  # testing for an empty sending host field.

  accept  hosts = :

  #############################################################################

  # The following section of the ACL is concerned with local parts that contain

  # @ or % or ! or / or | or dots in unusual places.

  #

  # The characters other than dots are rarely found in genuine local parts, but

  # are often tried by people looking to circumvent relaying restrictions.

  # Therefore, although they are valid in local parts, these rules lock them

  # out, as a precaution.

  #

  # Empty components (two dots in a row) are not valid in RFC 2822, but Exim

  # allows them because they have been encountered. (Consider local parts

  # constructed as "firstinitial.secondinitial.familyname" when applied to

  # someone like me, who has no second initial.) However, a local part starting

  # with a dot or containing /../ can cause trouble if it is used as part of a

  # file name (e.g. for a mailing list). This is also true for local parts that

  # contain slashes. A pipe symbol can also be troublesome if the local part is

  # incorporated unthinkingly into a shell command line.

  #

  # Two different rules are used. The first one is stricter, and is applied to

  # messages that are addressed to one of the local domains handled by this

  # host. It blocks local parts that begin with a dot or contain @ % ! / or |.

  # If you have local accounts that include these characters, you will have to

  # modify this rule.

  deny    message       = Restricted characters in address

          domains       = +local_domains

          local_parts   = ^[.] : ^.*[@%!/|]

  # The second rule applies to all other domains, and is less strict. This

  # allows your own users to send outgoing messages to sites that use slashes

  # and vertical bars in their local parts. It blocks local parts that begin

  # with a dot, slash, or vertical bar, but allows these characters within the

  # local part. However, the sequence /../ is barred. The use of @ % and ! is

  # blocked, as before. The motivation here is to prevent your users (or

  # your users' viruses) from mounting certain kinds of attack on remote sites.

  deny    message       = Restricted characters in address

          domains       = !+local_domains

          local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./

  #############################################################################

  # Accept mail to postmaster in any local domain, regardless of the source,

  # and without verifying the sender.

  accept  local_parts   = postmaster

          domains       = +local_domains

  # Deny unless the sender address can be verified.

  #  require verify        = sender

  #############################################################################

  # There are no checks on DNS "black" lists because the domains that contain

  # these lists are changing all the time. However, here are two examples of

  # how you could get Exim to perform a DNS black list lookup at this point.

  # The first one denies, while the second just warns.

  #

  # deny    message       = rejected because $sender_host_address is in a black list at $dnslist_domain\n$dnslist_text

  #         dnslists      = black.list.example

  #

  # warn    message       = X-Warning: $sender_host_address is in a black list at $dnslist_domain

  #         log_message   = found in $dnslist_domain

  #         dnslists      = black.list.example

  #############################################################################

  # Accept if the address is in a local domain, but only if the recipient can

  # be verified. Otherwise deny. The "endpass" line is the border between

  # passing on to the next ACL statement (if tests above it fail) or denying

  # access (if tests below it fail).

  accept  domains       = +local_domains

          endpass

          verify        = recipient

  # Accept if the address is in a domain for which we are relaying, but again,

  # only if the recipient can be verified.

  accept  domains       = +relay_to_rf

          endpass

          verify        = recipient

  accept  domains       = +relay_to_gs

          endpass

          verify        = recipient

  # If control reaches this point, the domain is neither in +local_domains

  # nor in +relay_to_domains.

  # Accept if the message comes from one of the hosts for which we are an

  # outgoing relay. Recipient verification is omitted here, because in many

  # cases the clients are dumb MUAs that don't cope well with SMTP error

  # responses. If you are actually relaying out from MTAs, you should probably

  # add recipient verification here.

  accept  hosts         = +relay_from_hosts

  # Accept if the message arrived over an authenticated connection, from

  # any host. Again, these messages are usually from MUAs, so recipient

  # verification is omitted.

  accept  authenticated = *

  # Reaching the end of the ACL causes a "deny", but we might as well give

  # an explicit message.

  deny    message       = relay not permitted

# These access control lists are used for content scanning with the exiscan-acl

# patch. You must also uncomment the entries for acl_smtp_data and acl_smtp_mime

# (scroll up), otherwise the ACLs will not be used. IMPORTANT: the default entries here

# should be treated as EXAMPLES. You MUST read the file doc/exiscan-acl-spec.txt

# to fully understand what you are doing ...

acl_check_mime:

  # Decode MIME parts to disk. This will support virus scanners later.

  warn decode = default

  # File extension filtering.

  warn message = Blacklisted file extension detected

       condition = ${if match \

                        {${lc:$mime_filename}} \

                        {\N(\.exe|\.pif|\.bat|\.scr|\.lnk|\.com)$\N} \

                     {1}{0}}

  

  # Reject messages that carry chinese character sets.

  # WARNING: This is an EXAMPLE.

  # deny message = Sorry, noone speaks chinese here

  #    condition = ${if eq{$mime_charset}{gb2312}{1}{0}}

  accept

acl_check_content:

  # Reject virus infested messages.

  deny  message = This message contains malware ($malware_name)

        malware = *

  # Add X-Scanned Header

  warn message = RF-Antivirus-Scanned: Clean

  # Always add X-Spam-Score and X-Spam-Report headers, using SA system-wide settings

  # (user "nobody"), no matter if over threshold or not.

  warn  message = RF-Spam-Score: $spam_score ($spam_bar)

        spam = nobody:true

  warn  message = RF-Spam-Report: $spam_report

        spam = nobody:true

  # Add X-Spam-Flag if spam is over system-wide threshold

  warn message = RF-Spam-Flag: YES

       spam = nobody

  # Reject spam messages with score over 7, using an extra condition.

  deny  message = This message scored $spam_score points. Congratulations!

        spam = nobody:true

        condition = ${if >{$spam_score_int}{70}{1}{0}}

  # finally accept all the rest

  accept

  

######################################################################

#                      ROUTERS CONFIGURATION                         #

#               Specifies how addresses are handled                  #

######################################################################

#     THE ORDER IN WHICH THE ROUTERS ARE DEFINED IS IMPORTANT!       #

# An address is passed to each router in turn until it is accepted.  #

######################################################################

begin routers

# This router routes to remote hosts over SMTP by explicit IP address,

# when an email address is given in "domain literal" form, for example,

# <user@[192.168.35.64]>. The RFCs require this facility. However, it is

# little-known these days, and has been exploited by evil people seeking

# to abuse SMTP relays. Consequently it is commented out in the default

# configuration. If you uncomment this router, you also need to uncomment

# allow_domain_literals above, so that Exim can recognize the syntax of

# domain literal addresses.

# domain_literal:

#   driver = ipliteral

#   domains = ! +local_domains

#   transport = remote_smtp

send_to_rf:

  driver = manualroute

  domains = +relay_to_rf

  transport = remote_smtp

  route_list = * exchangeserver.mydomain.local

send_to_gs:

  driver = manualroute

  domains = +relay_to_gs

  transport = remote_smtp

  route_list = * 2ndexchangeserver.mydomain.local

# This router routes addresses that are not in local domains by doing a DNS

# lookup on the domain name. Any domain that resolves to 0.0.0.0 or to a

# loopback interface address (127.0.0.0/8) is treated as if it had no DNS

# entry. Note that 0.0.0.0 is the same as 0.0.0.0/32, which is commonly treated

# as the local host inside the network stack. It is not 0.0.0.0/0, the default

# route. If the DNS lookup fails, no further routers are tried because of

# the no_more setting, and consequently the address is unrouteable.

dnslookup:

  driver = dnslookup

  domains = ! +local_domains

  transport = remote_smtp

  ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8

  no_more

# The remaining routers handle addresses in the local domain(s).

# This router handles aliasing using a linearly searched alias file with the

# name /etc/mail/aliases. When this configuration is installed automatically,

# the name gets inserted into this file from whatever is set in Exim's

# build-time configuration. The default path is the traditional /etc/aliases.

# If you install this configuration by hand, you need to specify the correct

# path in the "data" setting below.

#

##### NB  You must ensure that the alias file exists. It used to be the case

##### NB  that every Unix had that file, because it was the Sendmail default.

##### NB  These days, there are systems that don't have it. Your aliases

##### NB  file should at least contain an alias for "postmaster".

#

# If any of your aliases expand to pipes or files, you will need to set

# up a user and a group for these deliveries to run under. You can do

# this by uncommenting the "user" option below (changing the user name

# as appropriate) and adding a "group" option if necessary. Alternatively, you

# can specify "user" on the transports that are used. Note that the transports

# listed below are the same as are used for .forward files; you might want

# to set up different ones for pipe and file deliveries from aliases.

system_aliases:

  driver = redirect

  allow_fail

  allow_defer

  data = ${lookup{$local_part}lsearch{/etc/mail/aliases}}

# user = exim

  file_transport = address_file

  pipe_transport = address_pipe

# This router handles forwarding using traditional .forward files in users'

# home directories. If you want it also to allow mail filtering when a forward

# file starts with the string "# Exim filter" or "# Sieve filter", uncomment

# the "allow_filter" option.

# If you want this router to treat local parts with suffixes introduced by "-"

# or "+" characters as if the suffixes did not exist, uncomment the two local_

# part_suffix options. Then, for example, xxxx-foo@your.domain will be treated

# in the same way as xxxx@your.domain by this router. You probably want to make

# the same change to the localuser router.

# The no_verify setting means that this router is skipped when Exim is

# verifying addresses. Similarly, no_expn means that this router is skipped if

# Exim is processing an EXPN command.

# The check_ancestor option means that if the forward file generates an

# address that is an ancestor of the current one, the current one gets

# passed on instead. This covers the case where A is aliased to B and B

# has a .forward file pointing to A.

# The three transports specified at the end are those that are used when

# forwarding generates a direct delivery to a file, or to a pipe, or sets

# up an auto-reply, respectively.

userforward:

  driver = redirect

  check_local_user

# local_part_suffix = +* : -*

# local_part_suffix_optional

  file = $home/.forward

# allow_filter

  no_verify

  no_expn

  check_ancestor

  file_transport = address_file

  pipe_transport = address_pipe

  reply_transport = address_reply

# This router matches local user mailboxes. If the router fails, the error

# message is "Unknown user".

# If you want this router to treat local parts with suffixes introduced by "-"

# or "+" characters as if the suffixes did not exist, uncomment the two local_

# part_suffix options. Then, for example, xxxx-foo@your.domain will be treated

# in the same way as xxxx@your.domain by this router.

localuser:

  driver = accept

  check_local_user

# local_part_suffix = +* : -*

# local_part_suffix_optional

  transport = local_delivery

  cannot_route_message = Unknown user

######################################################################

#                      TRANSPORTS CONFIGURATION                      #

######################################################################

#                       ORDER DOES NOT MATTER                        #

#     Only one appropriate transport is called for each delivery.    #

######################################################################

# A transport is used only when referenced from a router that successfully

# handles an address.

begin transports

# This transport is used for delivering messages over SMTP connections.

remote_smtp:

  driver = smtp

# This transport is used for local delivery to user mailboxes in traditional

# BSD mailbox format. By default it will be run under the uid and gid of the

# local user, and requires the sticky bit to be set on the /var/mail directory.

# Some systems use the alternative approach of running mail deliveries under a

# particular group instead of using the sticky bit. The commented options below

# show how this can be done.

local_delivery:

  driver = appendfile

#  file = /var/mail/$local_part

  directory = /home/$local_part/.maildir

  maildir_format

  delivery_date_add

  envelope_to_add

  return_path_add

# group = mail

# mode = 0660

# This transport is used for handling pipe deliveries generated by alias or

# .forward files. If the pipe generates any standard output, it is returned

# to the sender of the message as a delivery error. Set return_fail_output

# instead of return_output if you want this to happen only when the pipe fails

# to complete normally. You can set different transports for aliases and

# forwards if you want to - see the references to address_pipe in the routers

# section above.

address_pipe:

  driver = pipe

  return_output

# This transport is used for handling deliveries directly to files that are

# generated by aliasing or forwarding.

address_file:

  driver = appendfile

  delivery_date_add

  envelope_to_add

  return_path_add

# This transport is used for handling autoreplies generated by the filtering

# option of the userforward router.

address_reply:

  driver = autoreply

######################################################################

#                      RETRY CONFIGURATION                           #

######################################################################

begin retry

# This single retry rule applies to all domains and all errors. It specifies

# retries every 15 minutes for 2 hours, then increasing retry intervals,

# starting at 1 hour and increasing each time by a factor of 1.5, up to 16

# hours, then retries every 6 hours until 4 days have passed since the first

# failed delivery.

# Address or Domain    Error       Retries

# -----------------    -----       -------

*                      *           F,2h,15m; G,16h,1h,1.5; F,4d,6h

######################################################################

#                      REWRITE CONFIGURATION                         #

######################################################################

# There are no rewriting specifications in this default configuration file.

begin rewrite

######################################################################

#                   AUTHENTICATION CONFIGURATION                     #

######################################################################

# There are no authenticator specifications in this default configuration file.

begin authenticators

######################################################################

#                   CONFIGURATION FOR local_scan()                   #

######################################################################

# If you have built Exim to include a local_scan() function that contains

# tables for private options, you can define those options here. Remember to

# uncomment the "begin" line. It is commented by default because it provokes

# an error with Exim binaries that are not built with LOCAL_SCAN_HAS_OPTIONS

# set in the Local/Makefile.

# begin local_scan

# End of Exim configuration file

```

When I test the Exim config, this is the output:

```

ASDRF8 root # exim -C /etc/exim/exim.conf -bV

Exim version 4.43 #1 built 20-Jan-2005 15:10:45

Copyright (c) University of Cambridge 2004

Berkeley DB: Sleepycat Software: Berkeley DB 4.1.25: (December 19, 2002)

Support for: iconv() IPv6 PAM Perl TCPwrappers OpenSSL

Lookups: lsearch wildlsearch nwildlsearch iplsearch cdb dbm dbmnz dsearch ldap ldapdn ldapm mysql passwd

Authenticators: cram_md5 plaintext spa

Routers: accept dnslookup ipliteral manualroute queryprogram redirect

Transports: appendfile/maildir/mailstore autoreply pipe smtp

Fixed never_users: 0

Contains exiscan-acl patch revision 28 (c) Tom Kistner [http://duncanthrax.net/exiscan/]

Configuration file is /etc/exim/exim.conf

```

So that seems to be ok. Just to be sure, here's my local.cf (spamassassin config file):

```

# This is the right place to customize your installation of SpamAssassin.

#

# See 'perldoc Mail::SpamAssassin::Conf' for details of what can be

# tweaked.

#

###########################################################################

#

# rewrite_header Subject *****SPAM*****

# report_safe 1

# trusted_networks 212.17.35.

# lock_method flock

body TEST_RULE_10 /spamtest10/i

score TEST_RULE_10 10

describe TEST_RULE_10 Adding 10 points to the spam score

body TEST_RULE_5 /spamtest5/i

score TEST_RULE_5 5

describe TEST_RULE_5 Adding 5 points to the spam score

```

So my config file is empty. I inserted the test rules afterwards.

----------

## cfvr

A little kick  :Smile: 

Maybe someone can put me on the right track here. I know it is a lot to read, but it has a very interesting plot  :Wink:  But I still need a good ending to this story  :Very Happy: 

----------

## adaptr

Hi again  :Wink: 

```
domainlist local_domains = @

domainlist relay_to_rf = mydomain.tld : my2nddomain.tld

domainlist relay_to_gs = subdomain.mydomain.tld 
```

This may introduce problems; specify the local domain instead of relying on hostname resolution to ensure it works the way you intend it to.

Depending on what the first line actually resolves to, it may be identical to or a subset of one of the other two domain lists.

Since exactly what happens will depend on the order the lists are searched/accessed, the problems you experience may occur intermittently instead of always.

Are the identical copies of messages delivered to the same exchange server or to different ones ?

Have you thoroughly checked the functioning of the exchange servers and their name resolution ?

Are the domain settings on the exchange boxes exactly the same as for Exim, i.e. do they actually expect to get those messages?

Assuming the Exim system works correctly, the most logical explanation is that one or another of the exchange servers is routing the messages back to Exim, forcing it to reprocess them.

That's one obvious disadvantage of munging your own mail server logs - I cannot use very much of the information you provide, since it is not actually true  :Wink: 

----------

## cfvr

I have heard this problem from only 4 users in the Exchange 5.5 server, the other is a 2000 Exchange server and none of these problems were mentioned. But, the email headers I posted in the first post were:

```

2005-02-18 00:03:29 1D1uYw-0001f3-Er <= sender@hisdomain.tld H=smtp3.euronet.nl [194.134.35.173] P=esmtp S=4317148 id=B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl

2005-02-18 00:03:36 1D1uYw-0001f3-Er => recipient@mydomain.tld R=send_to_rf T=remote_smtp H=exchangebox.mydomain.local [10.0.0.2]

2005-02-18 00:03:36 1D1uYw-0001f3-Er Completed

2005-02-18 01:25:41 1D1vra-00030B-Fo <= sender@hisdomain.tld H=smtp3.euronet.nl [194.134.35.173] P=esmtp S=4317148 id=B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl

2005-02-18 01:25:47 1D1vra-00030B-Fo => recipient@mydomain.tld R=send_to_rf T=remote_smtp H=exchangebox.mydomain.local [10.0.0.2]

2005-02-18 01:25:47 1D1vra-00030B-Fo Completed

2005-02-17 22:47:36 1D1tGK-0000Jl-RZ <= sender@hisdomain.tld H=smtp3.euronet.nl [194.134.35.173] P=esmtp S=4317148 id=B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl

2005-02-17 22:47:57 1D1tGK-0000Jl-RZ => recipient@mydomain.tld R=send_to_rf T=remote_smtp H=exchangebox.mydomain.local [10.0.0.2]

2005-02-17 22:47:57 1D1tGK-0000Jl-RZ Completed 
```

As you can see the previous MTA that sent this message to my Exim box was smtp3.euronet.nl and the Message ID is:

B2FFC356-80D4-11D9-B8C5-0003937A2332@euronet.nl

And thats the same for all three emails.

So it doenst look to me that the Exchange server resubmitted the email into Exim, it really looks to me that Exim somehow just sent this email several times. I did modify the TCP IP props of the Exchange 5.5 server to correct the DNS domain name, that was set incorrect by my predecessor. I corrected that to be hostname.mydomain.local, but other than that, the Exchange servers are configured properly, I'm quite sure of that. Before I just didnt have the Exim host in between, the Exchange servers received their email directly from the internet and the smart host was set to the SMTP server of our provider. Now the Exim host forwards the incoming emails to the corresponding Exchange servers and both Exchange servers have the Gentoo Exim box as their smart host. Outgoing emails are not duplicated.

And what do you mean specify the local domain? The Exim box doesnt need to receive SMTP emails from outside (or inside for that matter). Should I nontheless set that option to

```

domainlist local_domains = gentoohostname.mydomain.tld

```

?

----------

## adaptr

What I mean is that - hypothetically, at least - IF Exim has a domain/hostname that falls within one of the Exchange domains the following is possible:

- Exim gets mail for Xdomain1 but routed to Exim - entirely possible if the MX records reflect this.

- Exim then pushes it into its relay queue to the Exchange domain, again discovers it is supposed to handle this itself, and resubmits

Unlikely, sure - it still doesn't explain why the mails are sent multiple times.

But then, nothing I've seen so far explains that.

I'd start beating up the people who wrote that guide...

----------

## cfvr

Hmm.. too bad I'm the only one with this problem (I get that a lot  :Razz: )

Mkay ill start beating up the people who wrote that guide })

O no, I forgot, I'm a nice person  :Razz: 

----------

## adaptr

Tell you what - I'll take a look at that guide myself, and see what comes up.

I have a fair bit of experience manhandling MTA's, but very little with integrating scanners and the like, so we'm just have to see  :Wink: 

----------

## cfvr

OK sounds good! Tnxs  :Smile: 

But take into account I modified the howto to have Exim relay emails instead of making local deliveries. So I slightly modified some routers in Exim (as you can see..)

----------

## adaptr

Yes, I seen dat  :Wink: 

I do advise you to remove the local host (@) from the local domains setting, as you obviously never want mail delivered to the Gentoo box itself.

Avoiding any complications is good at this point.

----------

## cfvr

OK will do  :Smile: 

I changed that line in:

```

domainlist local_domains = gentoohostname.mydomain.local

```

that'l do I hope  :Smile: 

OK more and more people complain that they receive emails more that once. If I don't come up with a solution, i'll lose my job!  :Wink: 

Seriously; If I can't find a solution, I might consider switching to a different MTA. Any advice which MTA is best suited to use with clamav and spamassassin?

----------

## cfvr

I haven't looked into another MTA just yet, but I did have to disable spamassassin, because duplicate emails were getting out of control. Almost every user has had lots of duplicates.

----------

## adaptr

So... that means you have conclusively traced the behaviour to SA, then.

Very good.  :Wink: 

Personally, I am now running Exim on a Debian Woody system (have been for 2 years) but am in the process of switching to Postfix (on Gentoo, o'course) because I used  that before Exim, and although Exim is certainly fine enough as an MTA it just doesn't give me the fine-grained control and processing options that Postfix has.

I'm trying to get it to work with clamav, amavisd-new and dspam - which, sad to say, has been a total bitch so far... :Crying or Very sad: 

I do recommend Postfix unequivocally though - if you set it up with SASL or TLS to do as much remote work as possible it will be very secure - and it's easily one of the fastest MTAs on the planet.

(that last bit always impresses M$ clones, since sExchange on a single box has difficulty keeping up with as few as 100 clients - whereas Postfix on identical hardware will do 1000 users sending 100 mails a day with ease)

----------

## cfvr

OK, I'll try postfix then. I had to remove the Gentoo box from inbetween the internet and the Exchange server, because duplicate emails were out of control, even after disabling Spamassassin. So it was either Clam or Exim itself. Since no log produces any sort of lead where to look, I had to remove it from the message stream  :Neutral: 

But there will be a Gentoo MTA with Clamav and some sort of anti-spam as the email gateway or my name isn't cfvr! ( :Neutral: )

----------

## adaptr

There is an excellent Gentoo + Postfix + amavisd + clamav + spamassassin howto on the site:

http://www.gentoo.org/doc/en/mailfilter-guide.xml

Please don't tell me you haven't looked at that yet!

----------

## cfvr

 *adaptr wrote:*   

> Please don't tell me you haven't looked at that yet!

 

Although I'm not sure what that means  :Wink:  I haven't looked at that topique yet!  :Smile:  I have just emerged postfix and was looking around in Webmin (postfix has a nice module for postfix *yummie!* )

In other words; lookin' at it right now  :Smile: 

----------

## cfvr

 *adaptr wrote:*   

> There is an excellent Gentoo + Postfix + amavisd + clamav + spamassassin howto on the site:
> 
> http://www.gentoo.org/doc/en/mailfilter-guide.xml
> 
> Please don't tell me you haven't looked at that yet!

 

OK I think I found the problem, and it wasn't Exim/Gentoo  :Very Happy: 

It was a misconfiguration by my predecessor in the firewall config. Somehow he had mapped port 25 to the Exchange server, and installed a SMTP gateway in the firewall for SMTP sessions. The fact that didn't produce problems in the past may lie in the way we nowadays receive our email. We used to have bSmtp, so emails arrive at our ISP and the mails are being sent to our mailserver. Due to some problems according to SMTP email, I modified the MX records so that we now receive email directly from the sending mailservers, with the bSmtp solution as the backup MX.

Anyway.. I followed the postfix/amavisd/spamassassin/clam tutorial above and it's running top notch! It works like a charm, and noticeably faster that Exim I might add..

Thanks for helping me out (although no one could have helped me I guess..)

Regards,

Collin[/url]

----------

## adaptr

Well.. (devil's advocate here) I must point out to you that it was not, in fact, a case of misconfiguration by your predecessor; if it worked for his setup then it was obviously a correct configuration  :Wink: 

It's only misconfigured from your point of view, after shuffling the entire mail system around.

Rather difficult to blame him for that, isn't it ?

----------

## cfvr

Let me just say that his SMTP implementation violated some RFC's here and there  :Wink: 

----------

## rex123

I missed most of this thread, and there's nothing wrong with switching from exim to postfix, but...

exim (with exiscan-acl) has one big advantage in the area of spam/virus checking, which is that spam and virus checking can be built in to the SMTP transaction itself. This allows you to give an error (550) to the sending mail server/spammer if the mail is bad, rather than dropping or bouncing spam. This defers responsibility for the message back to whoever sent it. I like it :-)

----------

## cfvr

I'm not switching back  :Razz:  But I still have Exim + exiscan-acl + SA + Clamav at home  :Smile: 

I thought it was only possible with sa-exim to reject spam during the SMTP session, but you say it's also possible to do it with exiscan-acl?

----------

## rex123

 *cfvr wrote:*   

> I'm not switching back  But I still have Exim + exiscan-acl + SA + Clamav at home 
> 
> I thought it was only possible with sa-exim to reject spam during the SMTP session, but you say it's also possible to do it with exiscan-acl?

 

It is. And the exiscan-acl code is included in exim itself since 4.50, so you don't even need to patch if you have super-recent exim. I think sa-exim is more of a hack of exim, and exiscan-acl is probably likely to be better supported in future, because it does things the "right" way. It doesn't support "teergrubing" but it does everything else that sa-exim does. [Take this with a slight pinch of salt: I've never run sa-exim]

----------

## cfvr

OK, sounds good!

Maybe I'll switch back to Exim  :Razz: 

----------

## rex123

Don't you realise that exim vs postfix is a Holy War? You can't just keep changing sides like that! Next you'll be switching from vim to emacs (or vice versa), and you'll be in eternal confusion.

Cue someone saying that qmail is a far better MTA than anything else :-)Last edited by rex123 on Fri Mar 04, 2005 11:57 am; edited 1 time in total

----------

## cfvr

Well, I did hear this week that qmail hasn't had a security vulnerability since '96.. Since I'm quite sensitive to that kind of propaganda.. Let me switch to qmail! I don't have plans for the weekend anyway  :Wink: 

By the way, I just switched from nano to vim with syntax highlighting  :Very Happy: 

----------

