I swear that I have NOT changed ANY code pertaining to rules and/or delivery ... I have corrected vbscript/jscript script calling in POP3, IMAP and SMTP but that should NOT do this ...
Completely out of the blue I am now getting delivery errors ... And they are perfectly spot on !?!?!
I have a couple of global rules handling SPAM. The main ones are:
1: Score < 7 move to SPAM-folder AND copy to spam@mydomain..
2: Score > 6 copy to spam@mydomain AND delete mail..
The error message I get is: "Message delivery cancelled during global rules" ... Yes? I delete the email in the rule! Why bitch about this now?
This is triggered when it happens and I have had to insert a "file exist check" to avoid an entry in the ERROR logging.
.
Code: Select all
Sub OnDeliveryFailed(oMessage, sRecipient, sErrorMessage)
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim strRegEx, oMatch, oMatchCollection, strResult, strFilename
Dim EventLogX : Set EventLogX = New LogWriter
EventLogX.LogFile = "deliveryfail"
'
' Weird stuff
'
strRegEx = "^(?:.*Remote server replied:\s)([0-9]{3})(?:\s.*)$"
Set oMatchCollection = oLookup(strRegEx, sErrorMessage, False)
For Each oMatch In oMatchCollection
If oMatch.SubMatches.Count > 0 Then strResult = oMatch.SubMatches(0)
Next
EventLogX.Write( LPad("DeliveryFailed", 15, " ") & vbTab & "sRecipient = " & sRecipient )
EventLogX.Write( LPad("DeliveryFailed", 15, " ") & vbTab & "sErrorMessage = " & sErrorMessage )
EventLogX.Write( LPad("DeliveryFailed", 15, " ") & vbTab & "oMessage.Filename = " & oMessage.Filename )
'
' Return mail with message
'
If fso.FileExists(oMessage.Filename) Then
With CreateObject("hMailServer.Message")
strFilename = .Filename
fso.CopyFile oMessage.Filename, strFilename, True
.RefreshContent
.AddRecipient oMessage.HeaderValue("X-Envelope-From"), oMessage.HeaderValue("X-Envelope-From")
.Subject = "[* FAILED DELIVERY *] " & .Subject
.Body = LPad("DeliveryFailed", 15, " ") & vbTab & sRecipient & vbTab & strResult & vbNewLine & _
LPad("DeliveryFailed", 15, " ") & vbTab & sRecipient & vbTab & sErrorMessage & vbNewLine & .Body
.Save
End With
Else
EventLogX.Write( LPad("DeliveryFailed", 15, " ") & vbTab & "oMessage.Filename = ** DELETED **" )
End If
Set EventLogX = Nothing
Set oMatch = Nothing
Set oMatchCollection = Nothing
Set fso = Nothing
End Sub