Alternative ways of sendmail & cyrus integration [Was: Virtual domains, user@domain.com: Mailbox unknown]

Andrzej Filip anfi at priv.onet.pl
Tue Mar 9 03:42:20 EST 2004


William K. Hardeman wrote:
> --On Thursday, 26 February, 2004 18:10 +0100 Andrzej Filip 
> <anfi at priv.onet.pl> wrote:
> 
>> Below please find modified sendmail.mc lines to make sendmail check cyrus
>> mailbox existence using socket map [instead of fstat map]:
>> ----->
>> dnl
>> dnl *.mc file modifications for real time integration of cyrus and
>> sendmail
>> dnl
>> dnl It makes sendmail define user map in sendmail.cf
>> define(`LUSER_RELAY')
>> LOCAL_CONFIG
>> # cyrus - map for file stat checking
>> Kcyrus socket local:_path_to_smmapd_socket_
>> dnl
>> dnl
>> LOCAL_RULESETS
>> SLocal_localaddr
>> # Treat system mailboxes as usual
>> R$+             $: $(user $1 $)
>> R$+ <>          $@
>> # Detect cyrus mailboxes - deliver via cyrus mailer
>> R$+             $: $1 <$(cyrus $1 $: $)>
>> R$<$+>          $# cyrus $: @$1
>> # Treat remaining as usual
>> R$*             $@
>> <-----
>>
>> I hope will publish next version next week:
>> * capable to support cyrus virtual domains
>> * milter-sender friendly
>> [current version creates problems with checking local address validity]
> 
> 
> I couldn't get the above config to work in my patched sendmail 8.12.11, 
> so I've been playing around with it for several days now, and I've got 
> the following working for 99% of my situations. The only time it does 
> NOT work is in one virtual host situation. All of my other tests return 
> true.
> 
> -------<start domain.mc config>----------
> dnl # Local mailer definition
> define(`confLOCAL_MAILER', `cyrusv2virtdomain')dnl
> 
> dnl # Acceptable mailers
> MAILER(`local')dnl
> MAILER(`smtp')dnl
> MAILER(`cyrusv2virtdomain')dnl
> 
> dnl # Custom rulesets defined below
> 
> dnl # LOCAL_CONFIG custom definitions
> LOCAL_CONFIG
> # cyrus - map for checking cyrus maibox presence
> Kcyrus socket -T<TMPF> local:SMMAP_SOCKET
> 
> LOCAL_RULESETS
> SLocal_localaddr
> # Treat system mailboxes as usual
> R$+             $: $(user $1 $)
> R$+ <>          $@
> # Detect cyrus mailboxes - deliver via cyrus mailer
> R$*                             $: $1 $| $>"Cyrusvmap" $1
> R$+ $| $#ok                     $@ $# cyrusv2virtdomain $: @$1
> R$- @ $- . $* $| $#$*           $: $1@$2.$3 $| $>"Cyrusvmap" $1@$3
> R$+ $| $#ok                     $@ $# cyrusv2virtdomain $: @$1
> R$- + $* @ $- . $* $| $#$*      $: $1+$2@$3.$4 $| $>"Cyrusvmap" $1+$2@$4
> R$+ $| $#ok                     $@ $# cyrusv2virtdomain $: @$1
> R$- + $* @ $- . $* $| $#$*      $: $1+$2@$3.$4 $| $>"Cyrusvmap" $1+$2@$3.$4
> R$+ $| $#ok                     $@ $# cyrusv2virtdomain $: @$1
> R$+ $| $#$*                     $#$2
> # Treat remaning as usual
> R$*             $@
> 
> SCyrusvmap
> R$*             $: $(cyrus $1 $: $)
> R$@             $#error $@ nouser $: "551 Unknown user"
> -------<end domain.mc config>----------
> 
> For completeness, this is the cyrusv2.cf file modified per the Cyrus 
> 2.2.x to support virtual domains. I chose to create a new mailer instead 
> of just modifying the standard cyrusv2.cf file.
> 
> -------<start cyrusv2virtdomain.cf config>----------
> PUSHDIVERT(-1)
> #
> # Copyright (c) 2002 Sendmail, Inc. and its suppliers.
> #       All rights reserved.
> #
> # By using this file, you agree to the terms and conditions set
> # forth in the LICENSE file which can be found at the top level of
> # the sendmail distribution.
> #
> #       Contributed by Kenneth Murchison.
> #
> 
> _DEFIFNOT(`_DEF_CYRUSV2VIRTDOMAIN_MAILER_FLAGS', `lsDFMnqXz')
> _DEFIFNOT(`CYRUSV2VIRTDOMAIN_MAILER_FLAGS', `1A5@/:|m')
> ifdef(`CYRUSV2VIRTDOMAIN_MAILER_ARGS',, 
> `define(`CYRUSV2VIRTDOMAIN_MAILER_ARGS', `FILE /var/imap/socket/lmtp')')
> define(`_CYRUSV2VIRTDOMAIN_QGRP', 
> `ifelse(defn(`CYRUSV2VIRTDOMAIN_MAILER_QGRP'),`',`', ` 
> Q=CYRUSV2VIRTDOMAIN_MAILER_QGRP,')')dnl
> 
> POPDIVERT
> 
> #########################################
> ###   Cyrus V2 Mailer specification   ###
> #########################################
> 
> VERSIONID(`$Id: cyrusv2virtdomain.m4,v 1.5 2004/02/18 08:01:26 wont Exp $')
> 
> Mcyrusv2virtdomain,     P=[IPC], 
> F=_MODMF_(CONCAT(_DEF_CYRUSV2VIRTDOMAIN_MAILER_FLAGS, 
> CYRUSV2VIRTDOMAIN_MAILER_FLAGS),`CYRUSV2VIRTDOMAIN'),
>                S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n,
>                _OPTINS(`CYRUSV2VIRTDOMAIN_MAILER_MAXMSGS', `m=', `, 
> ')_OPTINS(`CYRUSV2VIRTDOMAIN_MAILER_MAXRCPTS', `r=', `, 
> ')_OPTINS(`CYRUSV2VIRTDOMAIN_MAILER_CHARSET', `C=', `, 
> ')T=DNS/RFC822/SMTP,_CYRUSV2VIRTDOMAIN_QGRP
>                A=CYRUSV2VIRTDOMAIN_MAILER_ARGS
> -------<end cyrusv2virtdomain.cf config>----------
> 
> As I mentioned above, there is one situation where I have found that the 
> above configuration does not work. This is when email is sent to a 
> canonical hostname in the virtual domain. For example, mail to 
> wont-i at wkh.org succeeds with no problems. Mail sent to 
> wont-i at mail.wkh.org, however, does not succeed. Where I've run into 
> problems, according to the debug, is that in the 2nd case, mail.wkh.org 
> never makes it into the mailertable definition, but gets rewritten to 
> the primary host's canonical hostname in the virtusertable steps, e.g., 
> wont-i at mail.wkh.org becomes wont-i at mail.hands-solutions.com. In the 
> first example, wont-i at wkh.org successfully makes it to the mailertable 
> lookup, and everything works successfully from there. Since I very very 
> rarely have any mail sent to the MX record's canonical host name, I can 
> live with this (for now anyway :-).
> 
> I hope this helps others fighting the same battle I've been fighting.


1) make SCyrusvmap handle temporary problems (e.g. cyrus turned off):

SCyrusvmap
R$*             $: $(cyrus $1 $: $)
R$*<TMPF>?	$#error $@ 4.3.0 $: "451 Temporary system failure."
R$@             $#error $@ nouser $: "551 Unknown user"

2) Sendmail converts CNAMES into "real names" in "preprocessing" stage.

-- 
Andrzej [en:Andrew] Adam Filip anfi at priv.onet.pl anfi at xl.wp.pl
http://anfi.webhop.net http://slashdot.org/~anfi
---
Home Page: http://asg.web.cmu.edu/cyrus
Wiki/FAQ: http://cyruswiki.andrew.cmu.edu
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html




More information about the Info-cyrus mailing list