[Mimedefang] md_check_against_smtp_server and md_graphdefang_log
Tilman Schmidt
t.schmidt at phoenixsoftware.de
Wed Mar 27 07:19:30 EDT 2013
Am 27.03.2013 01:43, schrieb James Curtis:
> I made the modification to /etc/sysconfig/mimedefang (still not sure why this is referred to as 'running with the -t option')
> MX_RECIPIENT_CHECK=yes
That sysconfig setting tells the init script to start MIMEdefang
with the -t option. "Running with the -t option" is low-level
speak, "running with MX_RECIPIENT_CHECK enabled" would be the
corresponding high-level expression.
> -------------Code----------------
> sub filter_recipient
> {
> my($recip, $sender, $ip, $host, $first, $helo, $rcpt_mailer, $rcpt_host, $rcpt_addr) = @_;
> return md_check_against_smtp_server($sender, $recip, "localhost", "192.168.1.10");
> }
> ------------Code-----------------
>
> I now get the following response before the data phase that rejects the user!
> 550 5.1.1 test at testdomain.com... User unknown
> -
> Yea! It's working
Good.
> I tried changing the code as suggested below:
> --------------Code-------------
> sub filter_recipient
> {
> my ($retval, $code, $dsn, $text) = md_check_against_smtp_server($sender, $recip, "localhost", "192.168.1.10");
> # if ($retval eq "Reject") {
> # md_graphdefang_log('notauser', $recip, $sender);
> # return action_discard
> #}
> #else{
> # md_graphdefang_log('valid', $retval, $code);
> # }
> }
> -------------Code--------------
I told you not to remove the first line
my($recip, $sender, ...) = @_;
Without that line, the $sender and $recip variables will not be set,
so your md_check_against_smtp_server call will try to check an empty
address.
I also told you to compare $retval to "REJECT" in all capitals in
your if statement because that's what md_check_against_smtp_server
will return. As it stands, the comparison will never be true so
the else branch will always be run.
And finally I told you to insert a return statement before the
closing brace. The code above will return an empty result, which
the caller doesn't expect.
Btw, "return action_discard" is not appropriate in filter_recipient
either. It should be something like "return('REJECT', 'You lose!');".
> Having tried with the remarked statement and having it fail, I remarked it back to just ther ecommended line and it still fails all email address', whether valid or not valid with this response:
> 501 5.5.4 Invalid Address
And quite rightly so. The empty address is indeed invalid as a
recipient. :-)
In sum, try something like this: (Sorry for the line wraps.)
-------------Code----------------
sub filter_recipient
{
my($recip, $sender, $ip, $host, $first, $helo, $rcpt_mailer,
$rcpt_host, $rcpt_addr) = @_;
my($retval, $code, $dsn, $text) =
md_check_against_smtp_server($sender, $recip, "localhost", "192.168.1.10");
if ($retval eq "REJECT") {
md_graphdefang_log('notauser', $recip, $sender);
return ('REJECT', 'go away');
}
else {
md_graphdefang_log('valid', $retval, $code);
return ('CONTINUE', 'ok');
}
}
------------Code-----------------
HTH
T.
--
Tilman Schmidt
Phoenix Software GmbH
Bonn, Germany
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
URL: <https://lists.mimedefang.org/pipermail/mimedefang_lists.mimedefang.org/attachments/20130327/4fa63080/attachment.sig>
More information about the MIMEDefang
mailing list