Re: [Mimedefang] Question about resend_message() (Sendmail)

2018-10-18 Thread Dianne Skoll
On Thu, 18 Oct 2018 09:57:40 -0400
John Von Essen  wrote:

> If I call delete_recipient(); with no argument, does it act as a
> catch-all and delete ALL recipients?

Nope.

> Or do have do something like:
> foreach(@Recipients) { delete_recipient($_); }

Yup.  You could wrap it in a delete_all_recipients() function if you like.

> Or could I just null the @Recipients array (@Recipients = ();
> add_recipient($SpamBox);)

Nope.  Anything you do in your filter that only affects memory within
the Perl process has absolutely no effect on Sendmail.  You have to
call one of the functions that communicates with Sendmail to actually
affect anything.

If you look at the source, you'll see that delete_recipient and
add_recipient make notes in the RESULTS file that ask the C code to
call appropriate milter functions to *actually* make the changes.

Regards,

Dianne.
___
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list MIMEDefang@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang


Re: [Mimedefang] Question about resend_message() (Sendmail)

2018-10-18 Thread John Von Essen
So I tried this:

$SpamBox = 'essenz_spam@localhost';

if ($hits < $req) {
action_change_header("X-NoSpam-Score", "$hits ($score) $names");
}
if ($hits >= $req && $hits < 15) {
action_change_header("X-Spam-Score", "$hits ($score) $names");
delete_recipient('j...@essenz.com');
add_recipient($SpamBox);
}
if ($hits >= 15) {
action_discard();
}

And it appears to work. But I am concerned about spammers trying to use 
alternate means of delivery, like my username @ FQDN, which is 
ess...@bjork.essenz.com not j...@essenz.com which is done in Sendmail’s 
virtusertable. 

If I call delete_recipient(); with no argument, does it act as a catch-all and 
delete “ALL” recipients?

Or do have do something like:

foreach(@Recipients)
{
delete_recipient($_);
}

Then

add_recipient($SpamBox);

Or could I just null the @Recipients array (@Recipients = (); 
add_recipient($SpamBox);)

It is a current Sendmail, and this server only serves one email user, me…

-John

> On Oct 18, 2018, at 9:30 AM, Dianne Skoll  wrote:
> 
> Hi,
> 
>>if ($hits >= $req) {
>>action_change_header("X-Spam-Score", "$hits ($score) $names");
>>resend_message($SpamBox);
>>action_discard();
>>} 
> 
> Rather than using resend_message to resend the message, if you have
> a new-enough version of Sendmail you can use delete_recipient to delete all
> of the original recipients and then add_recipient to add $SpamBox as
> a recipient.  You have to loop over @Recipients to delete all the
> original recipients.
> 
> Otherwise, you could add a magical header to the message and look for
> it the next time around.  You have to be careful to (1) delete the
> magical header before letting the mail go out if it's not being
> redirected, and (2) only trust it if the mail does originate from
> localhost.
> 
> Regards,
> 
> Dianne.
> ___
> NOTE: If there is a disclaimer or other legal boilerplate in the above
> message, it is NULL AND VOID.  You may ignore it.
> 
> Visit http://www.mimedefang.org and http://www.roaringpenguin.com
> MIMEDefang mailing list MIMEDefang@lists.roaringpenguin.com
> http://lists.roaringpenguin.com/mailman/listinfo/mimedefang


___
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list MIMEDefang@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang


Re: [Mimedefang] Question about resend_message() (Sendmail)

2018-10-18 Thread Dianne Skoll
Hi,

> if ($hits >= $req) {
> action_change_header("X-Spam-Score", "$hits ($score) $names");
> resend_message($SpamBox);
> action_discard();
> } 

Rather than using resend_message to resend the message, if you have
a new-enough version of Sendmail you can use delete_recipient to delete all
of the original recipients and then add_recipient to add $SpamBox as
a recipient.  You have to loop over @Recipients to delete all the
original recipients.

Otherwise, you could add a magical header to the message and look for
it the next time around.  You have to be careful to (1) delete the
magical header before letting the mail go out if it's not being
redirected, and (2) only trust it if the mail does originate from
localhost.

Regards,

Dianne.
___
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list MIMEDefang@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang


[Mimedefang] Question about resend_message() (Sendmail)

2018-10-18 Thread John Von Essen
So Im finishing up my MD setup. I want clean mail delivered to my local user 
account, Spam I want sent to another alternate local user account. So instead 
of quarantine, the spam goes to a dedicated spam account where I can check it 
manually every once in a awhile. So my MD filter code looks like this:


$SpamBox = 'essenz_spam@localhost';

if ($hits < $req) {
action_change_header("X-NoSpam-Score", "$hits ($score) $names");
}
if ($hits >= $req) {
action_change_header("X-Spam-Score", "$hits ($score) $names");
resend_message($SpamBox);
action_discard();
} 


The resend_message puts the spam in Sendmail’s clientmqueue, but…. 5 mins later 
when the queue flushes, the “resent” message gets delivered, which means it 
goes through MD again, which in turn gets filtered again by MD, resulting in a 
loop because it keeps getting flagged as spam then resent again.

Whats the easiest way to avoid this loop? Is there a way to put the message 
directly into the alternate mailbox (maybe add_recipient then 
delete_recipient)? The obvious option is I can add a snippet of code to MD to 
catch the loop and not perform a spam check on anything going to that alternate 
box.

Thanks
John
___
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list MIMEDefang@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang