How to block TLD's.

Discussion forum for Enterprise Edition.
Post Reply
jthanki
Posts: 4
Joined: Mon Nov 23, 2015 6:35 pm

How to block TLD's.

Post by jthanki »

Hello,
After getting way too many support calls about spam, i did something about this issue of .trade and .faith and all the .garbage tld's sending mail to us mailenable customers.

The fix is simple, and elegant, and even though this could be done within the system by ME, this is a decent and functional work around.

Open the smtp service properties. Go to advanced SMTP. Click on Configure under External Script. Check the box to enable script function for mail from. Click Edit Script. Update the ME_MAIL function to something like the following.

function ME_MAIL()

if %SENDERAUTH%=1 then
ME_ResultData = "250 %SENDER% connection from %IPADDRESS% authenticated." & Chr(13) & Chr(10)
else
ME_ResultData = "250 %SENDER% OK." & Chr(13) & Chr(10)
end if

if InStr("%SENDER%", ".trade]") > 1 then
ME_ResultData = "554 .trade domains not allowed to send us email." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".top]") > 1 then
ME_ResultData = "554 .trade domains not allowed to send us email." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".bid]") > 1 then
ME_ResultData = "554 .bid domains not allowed to send us email." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".date]") > 1 then
ME_ResultData = "554 .date domains not allowed to send us email." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".win]") > 1 then
ME_ResultData = "554 .win domains not allowed to send us email." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".stream]") > 1 then
ME_ResultData = "554 .stream domains not allowed to send us email." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

ME_MAIL = ME_Success

end function

Save, done. done. more elegant script's would be welcome to see from other users.

bitechbobbrenner
Posts: 41
Joined: Tue Jan 20, 2015 4:57 pm

Re: How to block TLD's.

Post by bitechbobbrenner »

Fantastic script!! I hope you dont mind but we expanded it bit, see below

'------------------- START -----------------

if InStr("%SENDER%", ".accountant]") > 1 then
ME_ResultData = "######## 554.19 .accountant domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".agency]") > 1 then
ME_ResultData = "######## 554.19 .agency domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".asia]") > 1 then
ME_ResultData = "######## 554.19 .asia domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".bid]") > 1 then
ME_ResultData = "######## 554.19 .bid domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".business]") > 1 then
ME_ResultData = "######## 554.19 .business domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".care]") > 1 then
ME_ResultData = "######## 554.19 .care domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".city]") > 1 then
ME_ResultData = "######## 554.19 .city domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".click]") > 1 then
ME_ResultData = "######## 554.19 .click domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".club]") > 1 then
ME_ResultData = "######## 554.19 .club domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".company]") > 1 then
ME_ResultData = "######## 554.19 .company domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".cricket]") > 1 then
ME_ResultData = "######## 554.19 .cricket domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".date]") > 1 then
ME_ResultData = "######## 554.19 .date domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".design]") > 1 then
ME_ResultData = "######## 554.19 .design domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".directory]") > 1 then
ME_ResultData = "######## 554.19 .directory domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".download]") > 1 then
ME_ResultData = "######## 554.19 .download domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".email]") > 1 then
ME_ResultData = "######## 554.19 .email domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".expert]") > 1 then
ME_ResultData = "######## 554.19 .expert domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".faith]") > 1 then
ME_ResultData = "######## 554.19 .faith domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".firm]") > 1 then
ME_ResultData = "######## 554.19 .firm domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".global]") > 1 then
ME_ResultData = "######## 554.19 .global domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".groupon.com]") > 1 then
ME_ResultData = "######## 554.19 .groupon.com domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".guide]") > 1 then
ME_ResultData = "######## 554.19 .guide domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".guru]") > 1 then
ME_ResultData = "######## 554.19 .guru domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".gurui]") > 1 then
ME_ResultData = "######## 554.19 .gurui domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".it]") > 1 then
ME_ResultData = "######## 554.19 .it domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".jobs]") > 1 then
ME_ResultData = "######## 554.19 .jobs domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".kz]") > 1 then
ME_ResultData = "######## 554.19 .kz domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".lawyer]") > 1 then
ME_ResultData = "######## 554.19 .lawyer domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".life]") > 1 then
ME_ResultData = "######## 554.19 .life domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".link]") > 1 then
ME_ResultData = "######## 554.19 .link domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".loan]") > 1 then
ME_ResultData = "######## 554.19 .loan domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".media]") > 1 then
ME_ResultData = "######## 554.19 .media domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".men]") > 1 then
ME_ResultData = "######## 554.19 .men domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".mobi]") > 1 then
ME_ResultData = "######## 554.19 .mobi domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".mobile]") > 1 then
ME_ResultData = "######## 554.19 .mobile domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".museum]") > 1 then
ME_ResultData = "######## 554.19 .museum domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".my]") > 1 then
ME_ResultData = "######## 554.19 .my domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".name]") > 1 then
ME_ResultData = "######## 554.19 .name domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".nato]") > 1 then
ME_ResultData = "######## 554.19 .nato domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".network]") > 1 then
ME_ResultData = "######## 554.19 .network domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".ninja]") > 1 then
ME_ResultData = "######## 554.19 .ninja domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".party]") > 1 then
ME_ResultData = "######## 554.19 .party domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".photography]") > 1 then
ME_ResultData = "######## 554.19 .photography domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".pro]") > 1 then
ME_ResultData = "######## 554.19 .pro domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".property]") > 1 then
ME_ResultData = "######## 554.19 .property domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".racing]") > 1 then
ME_ResultData = "######## 554.19 .racing domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".review]") > 1 then
ME_ResultData = "######## 554.19 .review domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".reviews]") > 1 then
ME_ResultData = "######## 554.19 .reviews domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".rocks]") > 1 then
ME_ResultData = "######## 554.19 .rocks domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".ru]") > 1 then
ME_ResultData = "######## 554.19 .ru domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".sale]") > 1 then
ME_ResultData = "######## 554.19 .sale domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".science]") > 1 then
ME_ResultData = "######## 554.19 .science domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".services]") > 1 then
ME_ResultData = "######## 554.19 .services domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".site]") > 1 then
ME_ResultData = "######## 554.19 .site domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".solutions]") > 1 then
ME_ResultData = "######## 554.19 .solutions domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".space]") > 1 then
ME_ResultData = "######## 554.19 .space domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".store]") > 1 then
ME_ResultData = "######## 554.19 .store domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".stream]") > 1 then
ME_ResultData = "######## 554.19 .stream domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".tips]") > 1 then
ME_ResultData = "######## 554.19 .tips domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".today]") > 1 then
ME_ResultData = "######## 554.19 .today domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".top]") > 1 then
ME_ResultData = "######## 554.19 .top domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".trade]") > 1 then
ME_ResultData = "######## 554.19 .trade domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".travel]") > 1 then
ME_ResultData = "######## 554.19 .travel domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".vip]") > 1 then
ME_ResultData = "######## 554.19 .vip domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".vn]") > 1 then
ME_ResultData = "######## 554.19 .vn domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".wang]") > 1 then
ME_ResultData = "######## 554.19 .wang domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".web]") > 1 then
ME_ResultData = "######## 554.19 .web domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".webcam]") > 1 then
ME_ResultData = "######## 554.19 .webcam domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".website]") > 1 then
ME_ResultData = "######## 554.19 .website domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".win]") > 1 then
ME_ResultData = "######## 554.19 .win domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".work]") > 1 then
ME_ResultData = "######## 554.19 .work domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".world]") > 1 then
ME_ResultData = "######## 554.19 .world domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".xxx]") > 1 then
ME_ResultData = "######## 554.19 .xxx domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

if InStr("%SENDER%", ".xyz]") > 1 then
ME_ResultData = "######## 554.19 .xyz domain emails are not accepted by this server." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if

rfwilliams777
Posts: 1370
Joined: Thu Nov 11, 2004 5:26 pm
Location: Kingsville, Texas

Re: How to block TLD's.

Post by rfwilliams777 »

You can create a filter and set the from to be *.tld (whatever the tld is). It works because I had to do it.
Robert Williams, Owner
www.WilliamsWebSolutions.com
#1 in MailEnable Business-Class Email Hosting - Switch to Williams Web Solutions and we will migrate your accounts to us for FREE!
We can be hired to help you with your Mail Enable server, too!

jthanki
Posts: 4
Joined: Mon Nov 23, 2015 6:35 pm

Re: How to block TLD's.

Post by jthanki »

The filters didnt work for me, as you still have to accept the message, make it go through all the stuff and then reject it, potentially clogging up ndr's and stuff.. i prefer to nip it at the bud.

I just added another bit to block the pesky *.*.us domains

if InStr("%SENDER%", ".us]") > 1 then
Dim test
test = "%SENDER%"
test = Mid(test, InStr(test, "@") + 1)
test = Mid(test, 1, InStr(test, "]") -1)
if UBound(Split(test, ".")) > 1 then
ME_ResultData = "554 .us domains not allowed to send us email." & Chr(13) & Chr(10)
ME_Mail = ME_Failure
Exit Function
end if
end if

i'm no vbs expert, but it works.

Walpitscheker
Posts: 2
Joined: Thu Aug 09, 2018 9:23 am

Re: How to block TLD's.

Post by Walpitscheker »

hey!

It's a bit old, but if someone search about it. You can make it a little shorter:


function ME_MAIL()

' if %SENDERAUTH%=1 then
' ME_ResultData = "250 %SENDER% connection from %IPADDRESS% authenticated." & Chr(13) & Chr(10)
' else
' ME_ResultData = "250 %SENDER% OK." & Chr(13) & Chr(10)
' end if

'--------------------- Blacklist tld
Blacklist=array("me","co","co.ua","xyz","biz","pw","club","tech","bid","website","site","win","top","space","press","trade","faith","racing","cricket","party","loan","science","review","stream","online","pro","date","biz","biz.ua","gob.ec","gob.gt")

for each DomainName in Blacklist

if InStr("%SENDER%","."&DomainName&"]")>0 then
ME_ResultData="554 5.7.1 ."&DomainName&" domains not allowed to send email to this server."&Chr(13)&Chr(10)
ME_Mail=ME_Failure
Exit Function
end if
next
'--------------------- Blacklist tld

ME_MAIL = ME_Success

end function

bitechbobbrenner
Posts: 41
Joined: Tue Jan 20, 2015 4:57 pm

Re: How to block TLD's.

Post by bitechbobbrenner »

Does anybody have a script that rather than block the .icu etc TLDs but allow only specific domain extensions like .com .net .gov .org .mil and so on? I've been attempting to modify the current above script with unsuccessful results.

kiamori
Posts: 329
Joined: Wed Nov 04, 2009 1:39 am
Contact:

Re: How to block TLD's.

Post by kiamori »

Should just be something like this,


Whitelist=array("com","net","org")

for each DomainName in Whitelist

if InStr("%SENDER%","."&DomainName&"]")<1 then
ME_ResultData="554 5.7.1 your TLD domain is not allowed to send email to this server."&Chr(13)&Chr(10)
ME_Mail=ME_Failure
Exit Function
end if
next

I would suggesting add quite a few more like .eu .ca .co .au etc...

dcol
Posts: 237
Joined: Fri May 26, 2017 11:25 pm

Re: How to block TLD's.

Post by dcol »

Old post, but I think it would be much better to have a filter that accepted the TLD's you want and send the rest to spam. That way at least you would never miss a legit email.

Post Reply