[Mimedefang] add_recipient and delete_recipient

Javier Kohan jktmp01 at gmail.com
Sat Jul 16 21:23:17 EDT 2016

El 14/7/2016 a las 19:09, Dianne Skoll escribió:
> That should all work; those functions can be called from anywhere.
> Are you seeing milter lines to the effect of:
> 2016-07-14T00:07:00.665002-04:00 colo14 sm-mta[30287]: u6E46wFK030287: Milter add: rcpt: userX at domain2.com
> 2016-07-14T00:07:00.664668-04:00 colo14 sm-mta[30287]: u6E46wFK030287: Milter delete: rcpt <userX at domain1.com>
> If you are not seeing that, then somehow MIMEDefang's results are not getting
> back to Sendmail properly.
No, I don`t see that in the logs.
My whole filter_recipient is below (initially was for checking in a
database for users allowed to receive mail from Internet and now I was
trying to divert some of those users to a new server we are testing)

 sub filter_recipient {
    my (
        $recipient, $sender,      $ip,        $host, $first,
        $helo,  $rcpt_mailer, $rcpt_host, $rcpt_addr
    ) = @_;
    my $dominio;
    my $recip;

    # Pelamos la direccion pura, pero no modificamos $recipient, para
    # poder usarlo despues.
    $recip = normaliza_email($recipient);
    md_syslog( 'info', "Mensaje para \"$recip\"" ) if ($debugear);

    # Si no se puede leer el dominio, dejamos que sendmail se ocupe.
    return ( 'CONTINUE', 'ok' ) unless ( $dominio =
extrae_dominio($recip) );

    # Si no es un dominio que figura en usuarios.db, lo maneja sendmail.
    return ( 'CONTINUE', 'ok' ) unless ( exists $dominios{$dominio} );

    # Es un dominio del usuarios.db, vemos si existe el usuario.
    if ( exists( $emails{$recip} ) ) {
        md_syslog( 'info', "Destinatario \"$recip\" existente" ) if
    else {
        md_syslog( 'info', "Destinatario \"$recip\" NO EXISTE" ) if
        return ( 'REJECT', "User unknown - Usuario desconocido", 550,
'5.1.1' );

    # Aca llega si el usuario existe. Veamos si hay que redirijirlo.
    if ( exists( $redirs{$recip} ) ) {
    my $usr;
        md_syslog( 'info', "Reescribiendo el dominio de \"$recip\" " )
if ($debugear);
    if ($usr=extrae_user($recip)) {
        my $newrec=$usr.'@'.$debug_dom;
        md_syslog('info',"Agregando \"$newrec\" al evelope");
        md_syslog('info',"Quitando \"$recipient\" del evelope");
    } else {
        md_syslog('warning',"No se pudo reescribir direccion de
    # Volvemos a sendmail
    return ( 'CONTINUE', 'ok' );

> What OS and Sendmail version are you running?
Debian Jessie (8.4), sendmail 8.14

> Regards,
> Dianne.


More information about the MIMEDefang mailing list