Setup catchall mail for sendmail

Hi all,

I' am trying to  setting up catchall - accounts for each virtualdomain hosted on our servers.

in /etc/mail/virtusertable y have

@domain         catchall@domain.com
@domain1       catchall@domain1.com

When y try to send mailnoexist@domain.com, then syslog says:

"SYSERR(root): rewrite: excessive recursion (max 50), ruleset canonify"

If I use an email address for a domain not hosted on this system (like catchall@otherdomain.com) as the recipient, then sendmail sends all mails, also those for existing users to catchall@otherdomain.com.

What I make wrong ?

Thanks for help!
PROCOM-REDESAsked:
Who is Participating?
 
moduloCommented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0
 
jlevieCommented:
What you need for the catchall would be:

bill@domain.tld          user1
...
@domain.tld                some-user
...
joe@domain1.tld         user2
...
@domain1.tld              some-user

You got the recursion error because the right hand side of the equate contained the domain present in the left hand side.  Provided that all other virutal email addresses are enumerated in virtusertable only those that don't match an explict entry will go to the catchall address.
0
 
PROCOM-REDESAuthor Commented:
Hi,

This mean that I must setup virtusertable  with all valid useraccounts present in a Domain ?

admin@domain.tld     admin
joe@domain.tld   joe
foo@domain.tld   foot
@domain.tld      catchall

Right ?

regards

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
jlevieCommented:
Yes. The chatch all simply means that any address not present in the virtuser table will resolve to the catchall destination.
0
 
PROCOM-REDESAuthor Commented:
OK, but....

Imagin a very very large mailsystem with hundreds of users in one or more domains.....

Is there an other solution more flexible and easier to manage than virtusertable ?

Thanks for your help!
0
 
PROCOM-REDESAuthor Commented:
Hi,

Other problem with catchall account for multiple domains.

I setup up for the primary domain "domain.tld":

admin@domain.tld     admin
joe@domain.tld   joe
foo@domain.tld   foo
@domain.tld      catchall

and it works fine when I send mail to a non existent user in that domain.

Now, I would like to setup in virtusertable the same for all other domains:

webmaster@newdomain.tld   webmaster
@newdomain.tld  catchall
webmaster@othernewdomain.tld  webmaster
@othernewdomain.tld  catchall
...
...
...


sendmail reject the mail for whatever@newdomain.tld whatever@othernewdomain.tld with the error "user unknown" and do not redirect the unknown recpient to catchall account.

Why ???

Need urgently a solution! Thanks




0
 
jlevieCommented:
After you added the new data to virtusertable did you re-make the map (usually 'makemap hash /etc/mail/virtusertable </etc/mail/virtusertable')?

Also did you add newdomain.tld & othernewdomain.tld to /etc/mail/local-host-names and restart sendmail?
0
 
PROCOM-REDESAuthor Commented:
Yes,

othernewdomain.com is present in local-host-names:

mail.othernewdomain.tld

virtusertable:

catchall@othernewdomain.tld     catchall
@othernewdomain.tld    catchall

and hashed: with makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable

MX record is also correct:

..
..
..

                MX      10      mail.othernewdomain.tld.
 
@               IN      A       194.224.164.3
www             IN      A       194.224.164.3
mail            IN      A       194.224.164.3

relay-domains:

othernewdomain.tld

and the most important for my system, mailertable:

othernewdomain.tld     cyrusv2d:/var/local/imap/socket/lmtp

It is  all present and I can't understand why it only works for the primary domain.

regards







0
 
jlevieCommented:
local-host-names should contain:

mail.othernewdom.tld
othernewdomain.tld

When using virtusertable relay-domains should be empty. And when using Cyrus the defintion of the cyrus mailer must be done in sendmail.mc and a new sendmail.cf built. For local accounts in Cyrus mailertable needs to also be an empty file unless you are using Cyrus' virtual domain support.

With a mailertable definition pointing to the lmtp socket mail of otherdomain is going straight to Cyrus and bypassing virtusertable. This means that you would have created accounts in Cyrus for webmaster@othernewdomain.tld and oan other users in otherdomain.tld. As far as I know there's no provision in the Cyrus virtual domain support for catchall's
0
 
PROCOM-REDESAuthor Commented:
I need to solve this problem but I cannot figure it out by my self. All documentation I ve found dont help. I am sure that I have the entire system correctly configured because it works all fine, all nice and realy powerfull !

The only thing that doesnt work is the catchall issue. Please have a look on the following systemconfiguration. Maybe you detect something wrong in this config.


OS = Solaris 9 sparc

mailsystem sendmail+cyrus+DB Berkeley+sieve+saslauth
-----------------------------------------------------------------
sendmail 8.13 with TLS/SSL for plaintext authentification, cyrus-sasl-2.1.18 with sasldb2 authentification for DIGEST-MD5
cyrus-imapd-2.2.8 (imapd, pop3) with sieve
Berkeley DB 4.2.52

sendmail.mc
---------------

divert(0)dnl
VERSIONID(`$Id: generic-solaris.mc,v 8.13 2001/06/27 21:46:30 gshapiro Exp $')dnl
 
OSTYPE(solaris8)dnl
DOMAIN(generic)dnl
 
define(`confAUTH_OPTIONS', `A p')dnl
define(`confAUTH_MECHANISMS', `LOGIN PLAIN DIGEST-MD5 CRAM-MD5')dnl
TRUST_AUTH_MECH(`LOGIN PLAIN DIGEST-MD5 CRAM-MD5')dnl
 
define(`confCACERT_PATH',`/usr/local/ssl/private')dnl
define(`confCACERT',`/usr/local/ssl/private/**************************ca.crt')dnl
define(`confSERVER_CERT',`/usr/local/ssl/private/***********************.crt')dnl
define(`confSERVER_KEY',`/usr/local/ssl/private/***************************.key')dnl
 
 
define(`confBIND_OPTS',`-DNSRCH -DEFNAMES')dnl
define(`confTO_IDENT',`0')dnl
 
define(`confLOCAL_MAILER', `cyrusv2d')dnl
define(`CYRUS_MAILER_FLAGS', `SA5@')dnl
define(`CYRUS_BB_MAILER_FLAGS', `S')dnl
define(`PROCMAIL_MAILER_PATH',`/opt/sfw/bin/procmail')dnl
 
define(`CYRUS_LMTP_SOCKET',`/var/local/imap/socket/lmtp')dnl
 
define(`confSMTP_LOGIN_MSG', `')dnl
define(`confPRIVACY_FLAGS', `authwarnings,goaway,noetrn')dnl
define(`confCOPY_ERRORS_TO', `admin')dnl
 
define(`ALIAS_FILE', `/etc/aliases')dnl
define(`STATUS_FILE', `/etc/mail/statistics')dnl
 
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl
DAEMON_OPTIONS(`Port=465, Name=TLSMTA, M=s')dnl
 
FEATURE(`preserve_local_plus_detail')dnl
 
FEATURE(virtusertable, hash /etc/mail/virtusertable)dnl
FEATURE(mailertable, hash /etc/mail/mailertable)dnl
FEATURE(domaintable, hash /etc/mail/domaintable)dnl
FEATURE(use_cw_file)dnl
FEATURE(use_ct_file)dnl
FEATURE(`nocanonify')dnl
FEATURE(`always_add_domain')dnl
 
FEATURE(`dnsbl',`blackholes.mail-abuse.org',`Mail Rejected. See http://www.mail-abuse.org')dnl
FEATURE(`dnsbl',`relays.ordb.org',`Mail Rejected. See http://relays.ordb.org')dnl
FEATURE(`dnsbl',`bl.spamcop.net',`Mail Rejected. See http://www.spamcop.net')dnl
 
FEATURE(local_procmail,`',`procmail -t -Y -a $h -d $u')dnl
FEATURE(access_db, hash -T<TMPF> /etc/mail/access)dnl
FEATURE(`blacklist_recipients')dnl
 
MAILER(local)dnl
MAILER(smtp)dnl
MAILER(cyrusv2d)dnl


imapd.conf
----------------
configdirectory: /var/local/imap
partition-default: /var/spool/imap
sievedir: /usr/local/sieve
sendmail: /usr/lib/sendmail
unixhierarchysep: yes
admins: userid
sieve_admins: userid
sasl_pwcheck_method: auxprop
sasl_auxprop_plugin: sasldb
tls_cert_file: /var/local/imap/***********************.crt
tls_key_file: /var/local/imap/*************************.key
tls_ca_file: /var/local/imap/******************************.crt
virtdomains: yes
defaultdomain: primary.tld
loginuseacl: yes
allowplaintext: no
allowanonymouslogin: no
autocreatequota: -1
quotawarn: 90



cyrus.conf
---------------

START {
  # do not delete this entry!
  recover       cmd="ctl_cyrusdb -r"
 
  # this is only necessary if using idled for IMAP IDLE
#  idled                cmd="idled"
}
 
# UNIX sockets start with a slash and are put into /var/imap/socket
SERVICES {
  # add or remove based on preferences
  imap          cmd="imapd" listen="imap" prefork=0
  imaps         cmd="imapd -s" listen="imaps" prefork=0
  pop3          cmd="pop3d" listen="pop3" prefork=0
  pop3s         cmd="pop3d -s" listen="pop3s" prefork=0
  sieve         cmd="timsieved" listen="sieve" prefork=0
 
  # these are only necessary if receiving/exporting usenet via NNTP
#  nntp         cmd="nntpd" listen="nntp" prefork=0
#  nntps                cmd="nntpd -s" listen="nntps" prefork=0
 
  # at least one LMTP is required for delivery
#  lmtp         cmd="lmtpd" listen="lmtp" prefork=0
  lmtpunix      cmd="lmtpd" listen="/var/local/imap/socket/lmtp" prefork=0
 
  # this is only necessary if using notifications
  notify        cmd="notifyd" listen="/var/local/imap/socket/notify" proto="udp" prefork=1
}
 
EVENTS {
  # this is required
  checkpoint    cmd="ctl_cyrusdb -c" period=30
 
  # this is only necessary if using duplicate delivery suppression,
  # Sieve or NNTP
  delprune      cmd="cyr_expire -E 3" at=0400
 
  # this is only necessary if caching TLS sessions
  tlsprune      cmd="tls_prune" at=0400
 
  # purge trash every day at midnight
  purgejunk     cmd="ipurge -d 6 -f */*/Junk*" period=8640
}


mailertable
-------------
subdomain.primary.tld      cyrusv2d:/var/local/imap/socket/lmtp
otherdomain.tld      cyrusv2d:/var/local/imap/socket/lmtp
newother.tld      cyrusv2d:/var/local/imap/socket/lmtp

relay-domains
--------------------
subdomain.primary.tld
otherdomain.tld
newother.tld


local-host-names
-------------------------
localhost

virtusertable
-----------------
admin@subdomain.primary.tld      admin
root@subdomain.primary.tld            root
postmaster@subdomain.primary.tld      postmaster
catchall@subdomain.primary.tld      catchall
@subdomain.primary.tld            catchall

webmaster@otherdomain.tld            webmaster
catchall@otherdomain.tld      catchall
@otherdomain.tld            catchall

webmaster@newother.tld      webmaster
catchall@newother.tld      catchall
@newother.tld            catchall


Thanks for any help......



0
 
jlevieCommented:
"virtdomains: yes" in imapd.conf means that you are using the Cyrus virutal domain support. And that in turn means that you don't use virtusertable and must create accounts with cyradm & saslpasswd for the the virutal addresses.
0
 
PROCOM-REDESAuthor Commented:
I am using cyradm and all mailboxes are created with. So, if virtdomains: yes is the hint for the catchall problem, is there any other way in cyrus to setup catchall accounts for each domain ?
0
 
jlevieCommented:
Not so far as I know. Catchall's are only available when Cyrus isn't configured with virtual domain support and routing of mail for virtual addresses is done with virtusertable.
0
 
PROCOM-REDESAuthor Commented:
Ok, seems to be nobody can't give me a solution. I can't believe that I am the only one with this problem.......

I found something that maybe can solve the problem, but before I make  signifcant changes on a production server I would like to ask an "expert":

What you mean about this ?!?!

http://anfi.homeunix.net/sendmail/localNalias.html


0
 
jlevieCommented:
I don't see haow that would help or work when Cyrus has virtual domain support enabled. In that case Cyrus expects to be given a full email address (user@virt-domain.tld) as the mail account ID. You can't map that through aliases or virtusertable because the rule would have to use the same address as the target, which is a circular definition.
0
 
PROCOM-REDESAuthor Commented:
well.... is it posible to put a rule in the sendmail.mc for a specific domain to send no existent usermail to a specific mailbox ?

This would be at least a temporal mini solution.

0
 
jlevieCommented:
That won't work with a Cyrus mail system. Sendmail doesn't have any knowledge of what users exist, that being entirely the province of Cyrus. I do recall that there is a patch for Sendmail that can reject mail for non-existant Cyrus accounts, but that wouldn't be of much help here. It might be possible to adapt the patch to do something else, but that would seem to be a non-trivial exercise.
0
 
anfiCommented:
IF you want sendmail reject messages to non existing cyrus-imap mailboxes in reply to "RCPT TO:" command
THEN apply http://anfi.homeunix.net/sendmail/localNalias.html
[ instead of  http://anfi.homeunix.net/sendmail/localNalias.html ]
0
 
PROCOM-REDESAuthor Commented:
0
 
anfiCommented:
:-)
You are right. Below please find corrected link:
http://anfi.homeunix.net/sendmail/rtcyrus2.html
0
 
jlevieCommented:
Yep that's the patch for rejecting mail to unknown users at the Sendmail level, but I don't see how it will help with the stated need for catchall's.
0
 
anfiCommented:
You can use it to redirect message to catchall address if there is no cyrus mailbox:

mailertable entry:
domain   mrs_cyrus_mailertable:local:catchall

Is it what you want?
0
 
PROCOM-REDESAuthor Commented:
I installed your solution at http://anfi.homeunix.net/sendmail/rtcyrus2.html

But I still unable to redirect non existent user to a global catchall account for each domain:

Now I working only with mailtertable and relay-domains

in mailtertable I have this:

firstdomain.net   mrs_cyrus_mailertable:local:catchall
seconddomain.com  mrs_cyrus_mailertable:local:catchall

in relay-domains I have this:

firstdomain.net
seconddomain.net

Testing with  sendmail -C sendmail.cf -d60.5 -bv webmaster@firstdomain.net
I receive following output:

map_lookup(dequote, admin, %0=admin) => NOT FOUND (0)
map_lookup(domaintable, firstdomain.net, %0=firstdomain.net) => NOT FOUND (0)
map_lookup(mailertable, firstdomain.net, %0=firstdomain.net) => mrs_cyrus_mailertable:local:catchall (0)
map_lookup(cyrus, webmaster@firstdomain.net, %0=webmaster@firstdomain.net) => webmaster@firstdomain.net<OK> (0)
webmaster@firstdomain.net... deliverable: mailer cyrusv2d, host dummy, user webmaster@firstdomain.net

This is OK (I belive) and when sending mail to webmaster@firstdomain.net works fine.

But using an non existent user like "whatever" seems to be work by testing it with
sendmail -C sendmail.cf -d60.5 -bv whatever@seconddomain.net

The output was the following:

map_lookup(dequote, admin, %0=admin) => NOT FOUND (0)
map_lookup(domaintable, seconddomain.net, %0=seconddomain.net) => NOT FOUND (0)
map_lookup(mailertable, seconddomain.net, %0=seconddomain.net) => mrs_cyrus_mailertable:local:catchall (0)
map_lookup(cyrus, whatever@seconddomain.net, %0=whatever@seconddomain.net) => NOT FOUND (68)
whatever@seconddomain.net... deliverable: mailer cyrusv2, host whatever@seconddomain.net, user catchall

But If sending mail to that non existent user it doesnt work. Syslog still say user unknown.

What I make wrong ? I forgot something ?

Thanks for any help.




0
 
PROCOM-REDESAuthor Commented:
Additionaly comment:

When sending mail to an non existent user I got this entry in syslog:

alias database /etc/aliases.db out of date
0
 
anfiCommented:
"aliases out of date" can be fixed by running newaliases commans (as root).
The command will recompile "binary aliases" used by sendmail from "text aliases" file.

For more details see "man newaliases"
0
 
anfiCommented:
"aliases out of date" => run newaliases command

Mailertable does not work for local email domains (listed in $=w)
Virtusertable works for local email domains ($=w) and domains listed in $={VirtHost}

Check if the domains are listed in $={VirtHost} using the dommand below:

echo '$={VirtHost}' | sendmail -bt

To add the domains to $={VirtHost} add the following lines to sendmail.mc and compile new sendmail.cf:
LOCAL_CONFIG
F{VirtHost}/etc/mail/virtual-domains

In /etc/mail/virtual-domains file list the domains (one domain per one line):
firstdomain.net

Read *carefully* about side effects of using standard sendmail.org methods of populating $={VirtHost} before using them.
0
 
PROCOM-REDESAuthor Commented:
I made this change as you described above, but still not working sending mail to whatever@firstdomain.net:

Nov 22 10:23:17 maschine sm-mta[3846]: [ID 801593 mail.info] iAM9NG2R003846: from=<user@domain.tld>, size=1378, class=0, nrcpts=1, msgid=<EMEBLPCNDKLJADFMKINOCEEACJAA.user@domain.tld>, proto=ESMTP, daemon=MTA, relay=smtp.domaindomain.tld [xxx.xxx.xxx.xxx]
Nov 22 10:23:17 machine sm-mta[3849]: [ID 702911 mail.info] alias database /etc/aliases.db out of date
Nov 22 10:23:17 machine sm-mta[3849]: [ID 801593 mail.info] iAM9NG2R003846: to=<whatever@firstdomain.net>, delay=00:00:00, xdelay=00:00:00, mailer=cyrusv2, pri=121378, relay=localhost, dsn=5.1.1, stat=User unknown
Nov 22 10:23:17 machine sm-mta[3849]: [ID 801593 mail.info] iAM9NG2R003846: iAM9NH2R003849: DSN: User unknown
Nov 22 10:23:19 machine sm-mta[3849]: [ID 801593 mail.info] iAM9NH2R003849: to=<user@domain.tld>, delay=00:00:02, xdelay=00:00:02, mailer=esmtp, pri=32625, relay=mail.domain.tld. [xxx.xxx.xxx.xxx], dsn=2.0.0, stat=Sent ( Message of 3691 Bytes Accepted for delivery)
Nov 22 10:23:19 machine sm-mta[3849]: [ID 801593 mail.info] iAM9NG2R003846: iAM9NH2S003849: postmaster notify: User unknown
Nov 22 10:23:19 machine sm-mta[3849]: [ID 801593 mail.info] iAM9NH2S003849: to=admin, delay=00:00:00, xdelay=00:00:00, mailer=cyrusv2, pri=30000, relay=localhost [[UNIX: /var/local/imap/socket/lmtp]], dsn=2.0.0, stat=Sent

0
 
PROCOM-REDESAuthor Commented:
Setting up cyrus with saslauth and sendmail was very easy, but the catchall problem seems to be the hardes thing for me to solve.

The only thing that I need is that each VIRTUAL DOMAIN have its own catchall mail address to cacht all incoming mails for nonexisten users in each VIRTUAL DOMAIN.


I made all as described in your mrs_cyrus solution (step 1 - 6) and it works if user exist (*):

map_lookup(dequote, admin, %0=admin) => NOT FOUND (0)
map_lookup(domaintable, firstdomain.net, %0=firstdomain.net) => NOT FOUND (0)
map_lookup(mailertable, firstdomain.net, %0=firstdomain.net) => mrs_cyrus_mailertable:local:catchall (0)
map_lookup(cyrus, webmaster@firstdomain.net, %0=webmaster@firstdomain.net) => webmaster@firstdomain.net<OK> (0)

(*)webmaster@firstdomain.net... deliverable: mailer cyrusv2d, host dummy, user webmaster@firstdomain.net


I dont need this (**), if user not exist:

map_lookup(dequote, admin, %0=admin) => NOT FOUND (0)
map_lookup(domaintable, firstdomain.net, %0=firstdomain.net) => NOT FOUND (0)
map_lookup(mailertable, firstdomain.net, %0=firstdomain.net) => mrs_cyrus_mailertable:local:catchall (0)
map_lookup(cyrus, nonexist@firstdomain.net, %0=nonexist@firstdomain.net) => NOT FOUND (68)

(**) nonexist@firstdomain.net... deliverable: mailer cyrusv2, host nonexist@firstdomain.net, user catchall


I need this (****):

(****) nonexist@firstdomain.net... deliverable: mailer cyrusv2d, host dummy, user catchall@firstdomain.net

QUESTION:

Is this posible with your mrs_cyrus solution ? And if, what more I need exactly ?


Thanks for any reply to solve this problem.
0
 
PROCOM-REDESAuthor Commented:
SOLVED by my self.

For all other peoples with the same problem: "catchall accounts for virtualdomains with sendmail 8.13.x and cyrus 2.2.x"

1. Install Andrzej Filip mrs_cyrus solution at http://anfi.homeunix.net/sendmail/rtcyrus2.html step 1 - 5
2. in sendmail.mc put:

dnl (host.domain.tld, send mail to user@host.domain.tld) dnl
define(`confLOCAL_MAILER', `cyrusv2d')dnl

dnl OR,  for your localdomain (send mail to user) dnl
define(`confLOCAL_MAILER', `cyrusv2')dnl

define(`CYRUS_MAILER_FLAGS', `SA5@')dnl
define(`CYRUS_BB_MAILER_FLAGS', `S')dnl
define(`CYRUS_LMTP_SOCKET',`/var/imap/socket/lmtp')dnl
define(`LOCAL_RELAY', `mrs_cyrus_mailertable:dummy')
FEATURE(mailertable, hash /etc/mail/mailertable)dnl
FEATURE(`mrs')dnl
FEATURE(`mrs_cyrus',`/var/local/imap/socket/smmapd')dnl
MODIFY_MAILER_FLAGS(`CYRUSV2',`-A5')dnl
MAILER(local)dnl
MAILER(smtp)dnl
MAILER(cyrusv2)dnl


3. mailertable

All what you need in mailertable for each virtualdomain with catchall account:

domain1.tld    mrs_cyrus_mailertable:cyrusv2d:catchall@domain1.tld
domain5.tld    mrs_cyrus_mailertable:cyrusv2d:catchall@domain5.tld

For domains without catchall mail put this:

domain8.tld    cyrusv2d:/var/imap/socket/lmtp

Feedback from anfi and jlevie is welcome

cheers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.