howart
asked on
mimefang and filter_recipient
How can I discard messages with mimedefang and filter recipient.
If I use the sugessted method i will produce backscatter
If I use the sugessted method i will produce backscatter
sub filter_recipient {
my($recip, $sender, $ip, $host, $first, $helo,
$rcpt_mailer, $rcpt_host, $rcpt_addr) = @_;
if ( md_check_against_smtp_server($sender, $recip,
"muncher.poppers.local","msx-poppers.poppers.local")){
md_syslog('info' , "MDLOG, $MsgID,unkownrecipient,$hostname,$ip");
return 'REJECT', "Recipient unkown" ;
}
# return md_check_against_smtp_server($sender, $recip,
# "muncher.poppers.local","msx-poppers.poppers.local");
return 'CONTINUE', 'ok';
}
ASKER
this does not work where am i going wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
got now this
but stil get a bounce
but stil get a bounce
sub filter_recipient {
my($recip, $sender, $ip, $host, $first, $helo,
$rcpt_mailer, $rcpt_host, $rcpt_addr) = @_;
# Check if recipient does exist on receiving mail server
my $file = "/tmp/testmd.log";
open (FILE, ">>$file");
my($smtp_status, $smtp_message) = md_check_against_smtp_server($Sender, $recip,
"muncher.poppers.local","192.168.1.13");
print FILE $smtp_status,$smtp_message,$Sender,$_,"\n";
if ( $smtp_status == 'CONTINUE' ) {
md_graphdefang_log($smtp_status,$_,'Recipient MSX exists');
return ("CONTINUE", "");
} else {
md_graphdefang_log('info' , "MDLOG, $MsgID,unkownrecipient,$hostname,$ip");
retrun ('DISCARD', "discarded");
}
close(FILE);
}
ASKER
I c the error
retrun instead of return
lets c if it works now
retrun instead of return
lets c if it works now
ASKER
does still not work
if ( $smtp_status == 'CONTINUE' ) {
should be:
if ( $smtp_status eq 'CONTINUE' ) {
(== if for numeric, eq for string compares).
(it would allways be true 0 == 0.)
running perl -cw <file>
can check a file for syntax errors.
should be:
if ( $smtp_status eq 'CONTINUE' ) {
(== if for numeric, eq for string compares).
(it would allways be true 0 == 0.)
running perl -cw <file>
can check a file for syntax errors.
ASKER
I have put the code in sub filter there it works!! :)
for some reason sub filter_recipient does not execute
Do you know what goes wrong there?
for some reason sub filter_recipient does not execute
Do you know what goes wrong there?
ASKER
here is my code in sub filter
# Check if recipient does exist on receiving mail server
my $file = "/tmp/test_md_filter.log";
open (FILE, ">>$file");
print FILE "youre now in mimdefang-filter sub filter\n";
foreach (@Recipients) {
my($smtp_status, $smtp_message) = md_check_against_smtp_server($Sender, $_,
"muncher.poppers.local","192.168.1.13");
print FILE $smtp_status,$smtp_message,$Sender,$_,"\n";
# print STDERR $smtp_status;
if ( $smtp_status eq 'CONTINUE' ) {
md_graphdefang_log($smtp_status,$_,'Recipient MSX exists');
} else {
md_graphdefang_log('info' , "MDLOG, $MsgID,unkownrecipient,$hostname,$ip");
#action_bounce('Unknown MSX recipient');
action_discard();
}
}
close(FILE);
Is there no problem when opening the file?
like: /tmp/test....log owned by another user?
Maybe it is better to add
md_syslog('info' , "MDLOG, $MsgID,unkownrecipient,$ho stname,$ip ");
Calls and check the syslog output for messages.
like: /tmp/test....log owned by another user?
Maybe it is better to add
md_syslog('info' , "MDLOG, $MsgID,unkownrecipient,$ho
Calls and check the syslog output for messages.
ASKER
When I use mimedefang with recipient_filter messages get rejected when i try to send to an unkown recipient.
So I made a routine in sub filter
Open in new window