I wrote a small script to log the Recipient Addresses of emails delivered via SMTP to hMailServer. I use it to look which addresses are used and how often. I used catchall at the past and do not know any address I am using. So the script generates a textfile like this (the number after the comma shows how often this address is used) :
Code: Select all
address1@domain1.net,3
address2@domain1.net,5
address1@domain2.net,2
Code: Select all
Public Const HMSDIR = "c:\hMailServer\" 'Path to hMailServer-Dir
...
Sub OnAcceptMessage(oClient, oMessage)
Dim objRecipient
Dim strAddress
On Error Resume Next
Err.Clear
For objRecipient = 0 to oMessage.Recipients.Count-1
strAddress = LCase(oMessage.Recipients(objRecipient).Address)
LogRecipient strAddress
Next
End Sub
...
Sub LogRecipient(strNewAddress)
Dim oFSO, tsDatei
Dim strLogFile, strValueAddress, strValueCount
Dim strNew, strTemp
Dim booUpdate
On Error Resume Next
Err.Clear
Set oFSO = CreateObject("Scripting.FileSystemObject")
strLogFile = HMSDIR & "Logs\hmailserver_Reciptions.log"
strNew = ""
booUpdate = False
If IsFileExists(strLogFile) = True Then
Set tsDatei = oFSO.OpenTextFile(strLogFile, 1)
Do Until tsDatei.AtEndOfStream
strTemp = tsDatei.ReadLine
strValueAddress = Mid(strTemp,1,InStr(1,strTemp,",")-1)
strValueCount = Mid(strTemp,InStr(1,strTemp,",")+1)
If strValueAddress = strNewAddress Then
strValueCount = CStr(CInt(strValueCount) + 1)
booUpdate = True
End If
strNew = strNew & strValueAddress & "," & strValueCount & vbCrLf
Loop
tsDatei.Close
If booUpdate = False Then
strNew = strNew & strNewAddress & ",1" & vbCrLf
End If
Set tsDatei = oFSO.OpenTextFile(strLogFile, 2)
tsDatei.Write strNew
tsDatei.Close
Else
Set tsDatei = oFSO.CreateTextFile(strLogFile, True)
tsDatei.WriteLine(strNewAddress & ",1")
tsDatei.Close
End If
Set tsDatei = Nothing
Set oFSO = Nothing
End Sub