Dont send message to a specific adress

Junior Member
User avatar
Posts: 39
Joined: Thu Nov 15, 2007 12:37 pm

Dont send message to a specific adress

Postby jheyne » Tue Mar 23, 2010 2:59 pm

Hello,

i used the search function but found nothing :(

What i have: A Mail (one Sender, n receiver)
What i need: A script that makes sure that a specific Adress will not receive any mails, but the others have to receive mails.
I tried

if(session.recipients[0].asText().toLowercase()==youdontreceive@mails.com){session.deleteMsg=true;}

but nobody receives messages then.

Any help on this please?

Thanks
jheyne

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

Postby Alexander Telegin » Tue Mar 23, 2010 3:18 pm

try

if(session.recipients[0].asText().toLowerCase()=='youdontreceive@mails.com') {session.deleteMsg=true;}

and check log for errors

Junior Member
User avatar
Posts: 39
Joined: Thu Nov 15, 2007 12:37 pm

Postby jheyne » Tue Mar 23, 2010 7:13 pm

Hy Alex,

thanks for the quick reply.

When i have one sender and many receivers and use

session.deleteMsg=true;

no email is sent because the whole session is deleted.
Is there a way to i "kill" only one mail (a specific adress) and not the whole session?

My scenario:

i have two trusted domains (domainA.com und domainB.com). The claim is if the sender AND the receiver have adresses in this trusted domains (e.g. sid@doaminA.com or diego@domainB.com), the mail will be sent, otherwise not.

Thanks for any hints,

jheyne

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

Postby Alexander Telegin » Wed Mar 24, 2010 11:21 am

like this?

Code: Select all
var sender = session.sender.asText().toLowercase();
var rcpt = session.recipients.asText().toLowercase();
var isSenderTrusted = sender.indexOf('@domainA.com') > 0 || sender.indexOf('@domainB.com') > 0;
var isRcptTrusted = rcpt.indexOf('@domainA.com') > 0 || rcpt.indexOf('@domainB.com') > 0;

if( !(isSenderTrusted && isRcptTrusted) ) {session.deleteMsg=true;}


Unfortunately there's no way to kill only one email if sessions look like this:

MAIL FROM:<sender>
RCPT TO:<rcpt1>
RCPT TO:<rcpt2>
...
RCPT TO:<rcptN>

You could try put scripts into OnMessage -> domainA and domainB slots. In this case eWall will see that different filters must be applied and will try to reset session and re-send the envelop information.

Junior Member
User avatar
Posts: 39
Joined: Thu Nov 15, 2007 12:37 pm

Postby jheyne » Wed Mar 24, 2010 7:00 pm

Hy Alex,

yes thats it.......... BUT.......

Unfortunately i need to stop sending the mail to the "untrusted" domain and not the whole session :(

I will try to solve it and if so i will be back with a big smile :D

Thanks for the help

jheyne

Junior Member
User avatar
Posts: 39
Joined: Thu Nov 15, 2007 12:37 pm

Postby jheyne » Thu Mar 25, 2010 8:02 am

'Alexander Telegin [SSS wrote:]like this?

Code: Select all
var sender = session.sender.asText().toLowercase();
var rcpt = session.recipients.asText().toLowercase();
var isSenderTrusted = sender.indexOf('@domainA.com') > 0 || sender.indexOf('@domainB.com') > 0;
var isRcptTrusted = rcpt.indexOf('@domainA.com') > 0 || rcpt.indexOf('@domainB.com') > 0;

if( !(isSenderTrusted && isRcptTrusted) ) {session.deleteMsg=true;}


Another idea:
Instead of
Code: Select all
if( !(isSenderTrusted && isRcptTrusted) ) {session.deleteMsg=true;}
Is it possible to change the "untrusted" recipient like this:
Code: Select all
if( !(isSenderTrusted && isRcptTrusted) ) {session.recipients[int]="mytrusted@domainB.com";}


???
Thanks
jheyne

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

Postby Alexander Telegin » Thu Mar 25, 2010 4:16 pm

Unfortunately, no. Because at OnMessage event the recipient list already sent to mail server. The only place where you can interceipt the recipients is the OnCommand event, occuring when mail client sent the command (for example, RCPT TO) and before it hit the server. If you find the recipient address unappropriate, you can replace the command with something neutral, for example, NOOP. Do you want an example?

Junior Member
User avatar
Posts: 39
Joined: Thu Nov 15, 2007 12:37 pm

Postby jheyne » Fri Mar 26, 2010 8:05 am

YES, Please!
Thanks

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

Postby Alexander Telegin » Fri Mar 26, 2010 11:22 am

Here you go (OnCommand event):

Code: Select all
var cmd = session.command.toUpperCase();
if ( cmd.indexOf('RCPT TO') == 0 ) {
   var email = new TEmailItem( cmd );
   var emailAddr = email.asText();
   email.free();
   if ( emailAddr == 'BAD@ADDR.COM' ) {
      session.command = 'NOOP';
   }
}

Return to Filters and scripts

Who is online

Users browsing this forum: No registered users and 1 guest