Rejection list of email address for a domain set as catch-all

Use this forum if you want to suggest a new feature to hMailServer. Before posting, please search the forum to confirm that it has not already been suggested.
Post Reply
p007138b
New user
New user
Posts: 1
Joined: 2020-03-07 17:58

Rejection list of email address for a domain set as catch-all

Post by p007138b » 2020-05-09 20:19

I guess the subject explains it.

I'd like to see a spot to add a list of (incoming) email addresses on the Domains->domain name--> advanced tab. Since the list will be only for the domain and the domain may also have aliases perhaps the list would just be the portion of the email address left of the @ sign (not the domain names)

The section could be called "Reject email addresses"

Under the catch-all address settings (under greylisting checkbox) I'd like to be able to add, change, delete this list of emails.

If an email address is on the list whenever that email address arrives instead of going into the catch-all that address would receive back either a 541, 550 during "rcpt to:" in the smtp negotiation.

On that same screen the rejection message could default to 541 or 550, but i'd also like to be also have a place to chose what message gets returned (maybe a choice of numbers, or even be able to add my own)

User avatar
jimimaseye
Moderator
Moderator
Posts: 8518
Joined: 2011-09-08 17:48

Re: Rejection list of email address for a domain set as catch-all

Post by jimimaseye » 2020-05-09 21:44

You might like this: https://www.hmailserver.com/forum/viewt ... 20&t=29306

Does your required list of addresses mean senders address (ie FROM)?

[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
mattg
Moderator
Moderator
Posts: 20788
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Rejection list of email address for a domain set as catch-all

Post by mattg » 2020-05-09 23:31

So why use a catch-all?
It seems like you want to selectively accept or reject mail

You could (should) do this with a script I reckon
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
jimimaseye
Moderator
Moderator
Posts: 8518
Joined: 2011-09-08 17:48

Re: Rejection list of email address for a domain set as catch-all

Post by jimimaseye » 2020-05-10 12:47

Sent: Sun May 10, 2020 4:16 am
by p007138b
On-the-fly Disposable/Catchall Addresses with Blacklisting is exactly what i am trying to accomplish.

I am using the catch-all address on the advanced tab to send all email to the domain to one address. I have been setting up emails with different companies. I.E. hmailserver@mydomain.com for the registration here on this forum.

I tried to configure it based on what you described on the posting, but nothing comes through except the main account i have set up as the "catch-all"

when i telnet to the server and attempt to do mail from: and rept to: when i put the address which should go into the catch-all i get "451 Please try again later"

On the distribution list i have announcements only selected and the catch-all address i want to use

under the routing tab, does it matter what port is used?

under the routing tab are the bottom two "when sender matches route, and when recipient matches route" left as default?


below is what i have for the eventhandlers.vbs file

Code: Select all

' Sub OnClientConnect(oClient)
' End Sub

Sub OnSMTPData(oClient, oMessage)
DisposableBlackList(oMessage)
End Sub

' Sub OnAcceptMessage(oClient, oMessage)
' End Sub

Sub OnDeliveryStart(oMessage)
DisposableBlackList(oMessage)
End Sub

' Sub OnDeliverMessage(oMessage)
' End Sub

' Sub OnBackupFailed(sReason)
' End Sub

' Sub OnBackupCompleted()
' End Sub

' Sub OnError(iSeverity, iCode, sSource, sDescription)
' End Sub

' Sub OnDeliveryFailed(oMessage, sRecipient, sErrorMessage)
' End Sub

' Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)
' End Sub

Function DisposableBlackList(oMessage)
Dim k, i, j, D, A, R, E, aUsername, oApp, oDomain, oDistributionList, cBlacklisted, DomainFound, RecipientDomain, DisposableBLExists
Set oApp = CreateObject("hMailServer.Application")
Call oApp.Authenticate("Administrator", "myhmailserverpassword")

R = oMessage.recipients.count
E = 0
For j = 0 To R -1
If oMessage.Recipients(j).IsLocalUser = false Then
aUsername = Split(oMessage.Recipients(j).Address,"@")
DomainFound = 0
RecipientDomain = lcase(aUsername(1))
For D = 0 to oApp.Domains.count-1
For A = 0 To oApp.Domains.item(D).DomainAliases.Count -1
If lcase(oApp.Domains.item(D).DomainAliases.Item(A).Aliasname) = RecipientDomain Then
RecipientDomain = lcase(oApp.Domains.Item(D).name)
End if
Next
if lcase(oApp.Domains.item(D).name) = RecipientDomain then
DomainFound = 1
Set oDomain = oApp.Domains.ItemByName(RecipientDomain)
DisposableBLExists = 0
For k = 0 To oDomain.DistributionLists.Count -1
If lcase(oDomain.DistributionLists.Item(k).Address) = lcase("DisposableBlacklist@" & RecipientDomain) Then
Set oDistributionList = oDomain.DistributionLists.Item(k)
if oDistributionList.Active and not oDistributionList.RequireSenderAddress = "" then
DisposableBLExists = 1
cBlacklisted = 0
For i = 0 To oDistributionList.Recipients.Count -1
If lcase(oDistributionList.Recipients.Item(i).RecipientAddress) = lcase(replace(oMessage.Recipients(j).Address,aUsername(1),RecipientDomain)) Then
Result.Value = 1
cBlacklisted = 1
R=R-1
eventlog.write(now() & " SMTP - CATCHALL BLACKLIST mail blocked to " & oMessage.recipients.item(j).address & " from " & oMessage.fromaddress )
End If
Next
if cBlacklisted = 0 then
ReDim preserve RecordedRecipients(E)
RecordedRecipients(E) = oDistributionList.RequireSenderAddress
E=E+1
End If
else
DisposableBLExists = 0
End If
End If
Next
If DisposableBLExists = 0 then
ReDim preserve RecordedRecipients(E)
RecordedRecipients(E) = oMessage.recipients.item(j).address
E=E+1
End if
End If
Next
if DomainFound = 0 then
ReDim preserve RecordedRecipients(E)
RecordedRecipients(E) = oMessage.recipients.item(j).address
E=E+1
End if
Else
ReDim preserve RecordedRecipients(E)
RecordedRecipients(E) = oMessage.recipients.item(j).address
E=E+1
End If
Next
if R > 0 then
oMessage.clearRecipients
For j = 0 to ubound(RecordedRecipients)
oMessage.AddRecipient "", RecordedRecipients(j)
Next
End if
End Function
Hello

I will address your email in steps:

1, You will always be better maintaining conversation in the forum (I have posted your PM to the thread and answering it here). Others can also answer and you will likely get a quicker response. (Avoid PM's unless it is personal details).

2,
I tried to configure it based on what you described on the posting, but nothing comes through except the main account i have set up as the "catch-all"
The script as posted works. I advise to review carefully what is required in the instructions from 1 through to 3. It does say that all disposable address will be delivered to the main account that is defined as the catchall (1d) after which you can use rules to distribute to other 'real' accounts as required but you need it setting up as instructed (pay attention to disabling you current 'catchall' account (1g) and ensuring you setup up the distribution list (1b). Do not skip any steps).

3,
when i telnet to the server and attempt to do mail from: and rept to: when i put the address which should go into the catch-all i get "451 Please try again later"
This is not related to my script but is more likely die to greylisting being enabled. Review your settings (or run https://www.hmailserver.com/forum/viewt ... 20&t=30914 so we can do it for you).

4,
under the routing tab, does it matter what port is used?
No but you must have the domain name correct.

Sent: Sun May 10, 2020 4:53 am
From: p007138b
Recipient: jimimaseye
I think I may have found a different solution.

If i add the email I want rejected as an account on the domain and uncheck the enable checkbox, the server responds to the telnet with "550 Account is not active" for that email address.
This is similar but not the same. The idea of my script means that you do not have to visit as Administrator and create every new account in HMS Admin prior to use and, instead, can simply quote the address as you wish. You only need to visit HMS Admin to add it to a block list if/when you want to disable it.
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

Post Reply