if senderdomain not exists

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

if senderdomain not exists

Postby chrigiboy » Sun May 16, 2010 11:38 am

I want to add a new rule with:

"if senderdomain not exists, THEN ...."

How can i do that?

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

Postby Alexander Telegin » Sun May 16, 2010 8:52 pm

If you mean local domain, try

if sender is not local
then ...

All local domains must be listed in eWall.

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

Postby chrigiboy » Tue May 18, 2010 9:41 pm

Hi, no i mean i want to check if the domain of the sender exist. I dont want to check the recepients. So, spammer cant use a domain as a sender, if it not exists

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

Postby Alexander Telegin » Wed May 19, 2010 8:50 am

This is what SPF for.

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

Postby chrigiboy » Sun Aug 22, 2010 10:32 pm

Hi,
i don't mean SPF. I want to add a rule, which checks, if the senderdomain exists or not, for all incomming emails. If someone want to send a email from *@domain-not-exist.tld to a local domain, then i want to reject the email. SPF just works, if the sender add a SPF record to the Nameserver. But i need a solution for any provider. I know, many emailprovider checks, if the domainname exists or not. Maybe a simple MX Record request or a request, if there any Nameserver entry for that domain. I don't know, what they really check, but i know, they check if the domainname exist or not. Why i should to deliver a email to a local mailbox, when the senderdomain doesn't exist.

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

Postby Alexander Telegin » Mon Aug 23, 2010 1:01 pm

Please try this script for OnSender event:

Code: Select all
var result = new TDNSResult();
var domain = session.sender.domain;
if ( domain.indexOf('.') > 0 ) {
   session.log( 'Checking domain ' + domain + ' ...' );
   if ( queryDNS( domain, 'A', result ) ) {
     if ( result.reply.count > 0 ) {
       session.log( 'Exists!' );
     } else {
       session.log( '!Domain doesn\'t publish A 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 » Mon Aug 30, 2010 11:21 pm

Looks very good. Thank you so much!

But i've got one small problem at least:

31.08.2010 01:17:16 82477 734 TXT: http://www.spamhaus.org/query/bl?ip=xx.xx.xx.xx
31.08.2010 01:17:16 82477 734 Applying action 'set reply 550 SPAM Blacklist response: {X-DNSBL-TXT}'
31.08.2010 01:17:16 82477 734 Applying action 'disconnect'
31.08.2010 01:17:16 82477 734 Applying action 'stop all filters'
31.08.2010 01:17:16 82477 734 Checking domain spamdomain.tld...
31.08.2010 01:17:16 82477 750 Exists!
31.08.2010 01:17:16 82477 781 Disconnect

It's not usefull to run the script, after i stop the mail with a filter rule. Should i use a Filterrule with 'and disconnect and stop all filters and don't run Scripts'? Now, i moved the file to onRecipient. So i can check 'OnSender' the DNSBL and with 'OnRecipient' i will check the domainname.


and i changed the follow line
if ( queryDNS( domain, 'A', result ) ) {
to
if ( queryDNS( domain, 'MX', result)) or if ( queryDNS( domain, 'A', result)) {

Maybe a A record doesn't exists... not everyone got 'A Record for website.tld' instead of 'A Record for http://www.website.tld'. So, a MX Record should everytime exists... also when the sender doesn't set-up an A Record for website.tld or http://www.website.tld.

I hope the 'OR' is on the right place. I think it works.

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

Postby Alexander Telegin » Tue Aug 31, 2010 11:18 am

The OR is Javascript looks like ||, so the whole "if" converts into

Code: Select all
if ( queryDNS( domain, 'MX', result)) || if ( queryDNS( domain, 'A', result)) {


To prevent this code from execution when upper filters stopped it, wrap the code like this:

Code: Select all
if (!session.stop){

 ... code ...

}

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

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

Hello,
It didn't work with '||'
!Script error: Identifier expected at Line: 5 - if ( queryDNS( domain, 'MX', result)) || if ( queryDNS( domain, 'A', result)) {

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

Postby Alexander Telegin » Wed Sep 01, 2010 7:51 am

Oops... too much brackets, try this:

Code: Select all
if ( queryDNS( domain, 'MX', result) || queryDNS( domain, 'A', result) ) {

Next

Return to Filters and scripts

Who is online

Users browsing this forum: No registered users and 1 guest