troubleshooting Question

Exim + Procmail = "Mail delivery failed"

Avatar of bignellrp
bignellrpFlag for United Kingdom of Great Britain and Northern Ireland asked on
Unix OSLinux NetworkingAntiSpam
9 Comments1 Solution4442 ViewsLast Modified:
I am trying to use procmail to filter my spam to a .Spam folder using Procmail.

I am using exim and have added the following procmail router/transport to my exim conf, but when i do all mails bounce.

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

procmail:
  debug_print = "R: procmail for $local_part@$domain"
  driver = accept
  domains = +local_domains
  check_local_user
  transport = procmail_pipe
  # emulate OR with "if exists"-expansion
  require_files = ${local_part}:\
                  ${if exists{/etc/procmailrc}\
                    {/etc/procmailrc}{${home}/.procmailrc}}:\
                  +/usr/local/bin/procmail
  no_verify
  no_expn

The vdom alias seems to work, but once i add the procmail part it fails.

Here is the output from exim log:

$ sudo exim -bt -d mail@foo.co.uk
Exim version 4.67 (FreeBSD 6.2) uid=0 gid=0 pid=84372 D=fbb95cfd
Probably Berkeley DB version 1.8x (native mode)
Support for: crypteq iconv() IPv6 use_setclassresources PAM Perl OpenSSL Content_Scanning Old_Demime
Lookups: lsearch wildlsearch nwildlsearch iplsearch cdb dbm dbmnz dnsdb dsearch nis nis0 passwd
Authenticators: cram_md5 plaintext spa
Routers: accept dnslookup ipliteral manualroute queryprogram redirect
Transports: appendfile/maildir/mailstore/mbx autoreply lmtp pipe smtp
Fixed never_users: 0
Size of off_t: 8
changed uid/gid: forcing real = effective
  uid=0 gid=0 pid=84372
  auxiliary group list: 0
seeking password data for user "mailnull": using cached result
getpwnam() succeeded uid=26 gid=26
seeking password data for user "root": cache not available
getpwnam() succeeded uid=0 gid=0
configuration file is /usr/local/etc/exim/configure
log selectors = 00000ffc 00212001
trusted user
admin user
seeking password data for user "mailnull": cache not available
getpwnam() succeeded uid=26 gid=26
originator: uid=0 gid=0 login=root name=Charlie Root
sender address = root@scud.foo.co.uk
Address testing: uid=0 gid=6 euid=0 egid=6
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Testing mail@foo.co.uk
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Considering mail@foo.co.uk
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
routing mail@foo.co.uk
--------> dnslookup router <--------
local_part=mail domain=foo.co.uk
checking domains
search_open: dsearch "/usr/local/etc/exim/virtual"
search_find: file="/usr/local/etc/exim/virtual"
  key="foo.co.uk" partial=-1 affix=NULL starflags=0
LRU list:
  4/usr/local/etc/exim/virtual
  End
internal_search_find: file="/usr/local/etc/exim/virtual"
  type=dsearch key="foo.co.uk"
file lookup required for foo.co.uk
  in /usr/local/etc/exim/virtual
lookup yielded: foo.co.uk
foo.co.uk in "@:localhost:dsearch;/usr/local/etc/exim/virtual"? yes (matched "dsearch;/usr/local/etc/exim/virtual")
data from lookup saved for cache for +local_domains: foo.co.uk
foo.co.uk in "! +local_domains"? no (matched "! +local_domains")
dnslookup router skipped: domains mismatch
--------> vdom_aliases router <--------
local_part=mail domain=foo.co.uk
checking domains
search_open: dsearch "/usr/local/etc/exim/virtual"
  cached open
search_find: file="/usr/local/etc/exim/virtual"
  key="foo.co.uk" partial=-1 affix=NULL starflags=0
LRU list:
  4/usr/local/etc/exim/virtual
  End
internal_search_find: file="/usr/local/etc/exim/virtual"
  type=dsearch key="foo.co.uk"
cached data used for lookup of foo.co.uk
  in /usr/local/etc/exim/virtual
lookup yielded: foo.co.uk
foo.co.uk in "dsearch;/usr/local/etc/exim/virtual"? yes (matched "dsearch;/usr/local/etc/exim/virtual")
calling vdom_aliases router
rda_interpret (string): ${expand:${lookup{$local_part}lsearch*@{/usr/local/etc/exim/virtual/$domain}}}
search_open: lsearch "/usr/local/etc/exim/virtual/foo.co.uk"
search_find: file="/usr/local/etc/exim/virtual/foo.co.uk"
  key="mail" partial=-1 affix=NULL starflags=2
LRU list:
  :/usr/local/etc/exim/virtual/foo.co.uk
  4/usr/local/etc/exim/virtual
  End
internal_search_find: file="/usr/local/etc/exim/virtual/foo.co.uk"
  type=lsearch key="mail"
file lookup required for mail
  in /usr/local/etc/exim/virtual/foo.co.uk
lookup yielded: foo
expanded: foo
file is not a filter file
parse_forward_list: foo
extract item: foo
vdom_aliases router generated foo@scud.foo.co.uk
  errors_to=NULL transport=NULL
  uid=unset gid=unset home=NULL
routed by vdom_aliases router
  envelope to: mail@foo.co.uk
  transport: <none>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Considering foo@scud.foo.co.uk
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
routing foo@scud.foo.co.uk
--------> dnslookup router <--------
local_part=foo domain=scud.foo.co.uk
checking domains
scud.foo.co.uk in "@:localhost:dsearch;/usr/local/etc/exim/virtual"? yes (matched "@")
scud.foo.co.uk in "! +local_domains"? no (matched "! +local_domains")
dnslookup router skipped: domains mismatch
--------> vdom_aliases router <--------
local_part=foo domain=scud.foo.co.uk
checking domains
search_open: dsearch "/usr/local/etc/exim/virtual"
  cached open
search_find: file="/usr/local/etc/exim/virtual"
  key="scud.foo.co.uk" partial=-1 affix=NULL starflags=0
LRU list:
  4/usr/local/etc/exim/virtual
  :/usr/local/etc/exim/virtual/foo.co.uk
  End
internal_search_find: file="/usr/local/etc/exim/virtual"
  type=dsearch key="scud.foo.co.uk"
file lookup required for scud.foo.co.uk
  in /usr/local/etc/exim/virtual
lookup failed
scud.foo.co.uk in "dsearch;/usr/local/etc/exim/virtual"? no (end of list)
vdom_aliases router skipped: domains mismatch
--------> procmail router <--------
local_part=foo domain=scud.foo.co.uk
checking domains
cached yes match for +local_domains
cached lookup data = NULL
scud.foo.co.uk in "+local_domains"? yes (matched "+local_domains" - cached)
checking for local user
seeking password data for user "foo": cache not available
getpwnam() succeeded uid=1001 gid=1001
R: procmail for foo@scud.foo.co.uk
checking require_files
seeking password data for user "foo": using cached result
getpwnam() succeeded uid=1001 gid=1001
check subsequent files for access by foo
file check: ${if exists{/etc/procmailrc}{/etc/procmailrc}{${home}/.procmailrc}}
expanded file: /home/foo/.procmailrc
stat() yielded 0
route_check_access(/home/foo/.procmailrc,1001,1001,4)
stat /usr
stat /usr/home
stat /usr/home/foo
stat /usr/home/foo/.procmailrc
route_check_access() succeeded
file check: +/usr/local/bin/procmail
expanded file: /usr/local/bin/procmail
stat() yielded 0
route_check_access(/usr/local/bin/procmail,1001,1001,4)
stat /usr
stat /usr/local
stat /usr/local/bin
stat /usr/local/bin/procmail
route_check_access() succeeded
calling procmail router
procmail router called for foo@scud.foo.co.uk
  domain = scud.foo.co.uk
set transport procmail_pipe
queued for procmail_pipe transport: local_part = foo
domain = scud.foo.co.uk
  errors_to=NULL
  domain_data=NULL localpart_data=NULL
routed by procmail router
  envelope to: foo@scud.foo.co.uk
  transport: procmail_pipe
foo@scud.foo.co.uk
    <-- mail@foo.co.uk
  router = procmail, transport = procmail_pipe
search_tidyup called
>>>>>>>>>>>>>>>> Exim pid=84372 terminating with rc=0 >>>>>>>>>>>>>>>>


Here is a cat from my .forward file and my .procmailrc:

(foo@scud)-(23:51:57)-(~)
$ cat .forward
|exec /usr/local/bin/procmail -f- /home/foo/.procmailrc
(foo@scud)-(23:53:30)-(~)
$ cat .procmailrc
#----------------------------------------------------------------------#
# Your procmail logfile will grow rapidly so remember to comment out
# the first line "LOGFILE=$HOME/.procmailrc.log" once you've verified
# that procmail is performing as expected

LOGFILE=$HOME/.procmailrc.log
VERBOSE=yes
COMSAT=no
MAILDIR=$HOME/Maildir
PATH=/usr/local/bin:/usr/bin

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

# (part 1)
# The following entries will invoke spamassassin to catch SPAM
# and put into "caughtspam" folder in your Mail directory. You can go
# through the "caughtspam" folder using pine or mutt and remove the
# messages there.  The 2nd line "* < 25600" is to scan messages less
# than 256KB only.  You can comment out the 2nd line if you want to
# scan all messages.

:0fw:spamassassin.lock
* < 256000
| /usr/local/bin/spamc

:0:
* ^X-Spam-Status: Yes
.Spam

#---------------------------------------------------------------------#
# (part 2)
# Add your own filtering commands here, if you want.
#---------------------------------------------------------------------#

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

# (part 3) How to set up vacation message

#   1. No need to set up .forward file if you use this method.
#   2. Prepare .vacation.msg in your home directory.
#   3. Run "vacation -I" command.
#   4. Uncomment the 2 lines below (Did you replace your_loginname with yours?)
#   5. Remember to comment out the 2 lines when you come back from vacation.

#:0 c
#| /usr/bin/vacation your_loginname


Here is the header from the failed mail:

X-Message-Status: sF:0
X-SID-PRA: Mail Delivery System <Mailer-Daemon@scud.foo.co.uk>
X-Message-Info: txF49lGdW434iBjPR2JS8MpohOUUHEFgM3S9sx4cKJUaAbUw+azooK8aUZoymK6P
Received: from scud.foo.co.uk ([212.74.113.130]) by bay0-mc3-f3.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668);
       Sun, 29 Jul 2007 15:49:05 -0700
Received: from mailnull by scud.foo.co.uk with local (Exim 4.67 (FreeBSD))
      id 1IFHWz-000Lwj-NS
      for foo@hotmail.com; Sun, 29 Jul 2007 23:46:33 +0100
X-Failed-Recipients: foo@scud.foo.co.uk
Auto-Submitted: auto-replied
From: Mail Delivery System <Mailer-Daemon@scud.foo.co.uk>
To: foo@hotmail.com
Subject: Mail delivery failed: returning message to sender
Message-Id: <E1IFHWz-000Lwj-NS@scud.foo.co.uk>
Date: Sun, 29 Jul 2007 23:46:33 +0100
Return-Path: <>
X-OriginalArrivalTime: 29 Jul 2007 22:49:05.0492 (UTC) FILETIME=[AA8D1940:01C7D232]

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

  foo@scud.foo.co.uk
    (generated from mail@foo.co.uk)
    local delivery failed

------ This is a copy of the message, including all the headers. ------

Return-path: <foo@hotmail.com>
Received: from bay0-omc3-s14.bay0.hotmail.com ([65.54.246.214])
      by scud.foo.co.uk with esmtp (Exim 4.67 (FreeBSD))
      (envelope-from <foo@hotmail.com>)
      id 1IFHWw-000Lwe-91
      for mail@foo.co.uk; Sun, 29 Jul 2007 23:46:33 +0100
Received: from BAY126-W11 ([65.55.131.46]) by bay0-omc3-s14.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668);
       Sun, 29 Jul 2007 15:48:54 -0700
Message-ID: <BAY126-W11B94C791CD2E6DF5207CAAAED0@phx.gbl>
Content-Type: multipart/alternative;
      boundary="_998b3643-0801-429b-a7da-86de8112fca0_"
X-Originating-IP: [212.74.112.53]
From: Rik Bignell <foo@hotmail.com>
To: mail <mail@foo.co.uk>
Subject: TEST2350
Date: Sun, 29 Jul 2007 23:48:54 +0100
Importance: Normal
MIME-Version: 1.0
X-OriginalArrivalTime: 29 Jul 2007 22:48:55.0096 (UTC) FILETIME=[A45ACB80:01C7D232]

--_998b3643-0801-429b-a7da-86de8112fca0_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

TEST2350
_________________________________________________________________
Feel like a local wherever you go with BackOfMyHand.com
http://www.backofmyhand.com=

--_998b3643-0801-429b-a7da-86de8112fca0_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body>TEST2350<br /><hr />Email straight to your blog, upload jokes, photos=
 and more.  <a href=3D'http://specials.uk.msn.com/spaces/default.aspx ' tar=
get=3D'_new'>Windows Live Spaces, it's FREE!</a></body>
</html>=

--_998b3643-0801-429b-a7da-86de8112fca0_--
</
ASKER CERTIFIED SOLUTION
Arty Nopius
system engineer
Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros