if senderdomain not exists

Junior Member
Posts: 25
Joined: Mon Mar 10, 2008 10:27 am

Postby chrigiboy » Wed Sep 01, 2010 8:43 am

Looks good now:
Code: Select all
if (!session.stop){
var result = new TDNSResult();
var domain = session.sender.domain;
if ( domain.indexOf('.') > 0 ) {
   session.log( 'Checking domain ' + domain + ' ...' );
if ( queryDNS( domain, 'MX', result) || queryDNS( domain, 'A', result) ) {
     if ( result.reply.count > '0' ) {
       session.log( domain + ' exists!' );
     } else {
       session.log( '!Domain ' + domain + ' doesn\'t publish A / MX record' );
       session.reply = '421 Invalid Sender Domain';
     }
  } else {
     session.log( '!' + result.error );
  }
  result.free();
}
}

Junior Member
Posts: 25
Joined: Mon Mar 10, 2008 10:27 am

Postby chrigiboy » Wed Sep 01, 2010 10:01 am

There is a small Bug.
When there is no MX Entry, the email will be blocked. Also when a 'A'-Record exists.
I've changed 'MX' with 'A' on the filter. The Email will be blocked, when no 'A'-Record exists. Also when a 'MX'-Record exists.
|| looks like a 'AND' and not a 'OR'.

Developer
User avatar
Posts: 4431
Joined: Tue Apr 20, 2004 3:43 pm

Postby Alexander Telegin » Wed Sep 01, 2010 9:22 pm

And is &&. You could add some logging checkpoints to the code to debug it.

Previous

Return to Filters and scripts

Who is online

Users browsing this forum: No registered users and 1 guest