How can I bypass attachment blocking for a domain name.
I have blocked .doc extensions etc .. following the spread of a virus.
However, some more experienced users are complaining that they must receive doc files.
I cannot create ranges of ip for each contact of my clients.
there is a way to allow only a certain domain name to receive these files?
Exclude attachment blocking for a domain name
Re: Exclude attachment blocking for a domain name
You would need to script the removal of .doc files and stop mail for your domain using that function
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation
https://www.hmailserver.com/documentation
Re: Exclude attachment blocking for a domain name
thanks you put me on the right path
I tried to use this script
https://www.hmailserver.com/forum/viewt ... 75#p165892
The deletion works fine, but I can't get the notification. Can someone help me?
I tried to use this script
https://www.hmailserver.com/forum/viewt ... 75#p165892
The deletion works fine, but I can't get the notification. Can someone help me?
Code: Select all
Sub DeleteAttachments(oMessage)
' this routine deletes or quarantines file attachments that have the specified
' FileExtensions. It replaces the functionality of antivirus blocked attachments panel in hmailadmin
' and also has a selectable quarantine option
Dim Quarantine ' set to True to Quarantine or False to Delete attachments
Quarantine = False
Dim QuarantineFolder 'where to store quarantined attachments. This folder must already exist.
QuarantineFolder = "c:\path to quarantine folder\" ' trailing slash is required
Dim QuarantineFile
Dim FileExtensions ' set to the file attachment extensions you want to delete or quarantine
FileExtensions = "(bat|cmd|com|cpl|csh|docm|exe|pif|hta|htb|inf|js|jse|lnk|msi|msp|pif|reg|scf|scr|shs|shb|vbe|vbs|wsf|wsh)"
' change anything below here at your own risk.
Dim AttachmentDeleteNotify
AttachmentDeleteNotify = Empty
Dim oAttachment
Dim oRegExp
Set oRegExp = new RegExp
For oAttachment = 0 to oMessage.Attachments.Count-1
' Test for undesirable attachments
with oRegExp
.Pattern = "^.*\."& FileExtensions & "$"
.IgnoreCase = True
.Global = False
end with
if (oRegExp.test(oMessage.Attachments(oAttachment).Filename)) Then
' Delete Attachment
AttachmentDeleteNotify = AttachmentDeleteNotify & oMessage.Attachments(oAttachment).Filename & "~"
If (Quarantine) Then
QuarantineFile = QuarantineFolder & Left(Right(oMessage.Filename,42),38) _
& "." & oAttachment & "." & oMessage.Attachments(oAttachment).Filename & "." & ".Quarantined"
oMessage.Attachments(oAttachment).SaveAs(QuarantineFile)
oMessage.Attachments(oAttachment).Delete
Else
oMessage.Attachments(oAttachment).Delete
End If
End If
Next
Set oRegExp = nothing
If Not IsEmpty(AttachmentDeleteNotify) then
AttachmentDeleteNotify = "The following attachment/s were blocked for delivery by the e-mail server." & "~" _
& "Please contact your system administrator if you have any questions regarding this." & "~" & "~" _
& "Notice ID: " & Left(Right(oMessage.Filename,42),38) & "~" & "~" _
& AttachmentDeleteNotify _
& "~" & "Mail Server Admin" & "~" & "~"
Dim htmlNotify
htmlNotify = AttachmentDeleteNotify
If ( Len(oMessage.Body) <> 0 ) Then
AttachmentDeleteNotify = Replace(AttachmentDeleteNotify, "~", VbCrLf)
oMessage.Body = oMessage.Body & VbCrLf & VbCrLf & AttachmentDeleteNotify
End If
If ( Len(oMessage.HTMLBody) <> 0 ) Then
htmlNotify = Replace(htmlNotify, "~", ("<br>" & VbCrLf))
oMessage.HTMLBody = Replace(oMessage.HTMLBody, "</body", ("<br><br>" & htmlNotify & "</BODY"), 1, 1, vbTextCompare)
End If
oMessage.Save
End If
End Sub
Re: Exclude attachment blocking for a domain name
Please someone who can help me I can't send the notification, it's Important
Re: Exclude attachment blocking for a domain name
Are there any errors in your error log?
Did you look in your hmailserver log for any clues?
How are you calling the script?
Did you look in your hmailserver log for any clues?
How are you calling the script?
Re: Exclude attachment blocking for a domain name
Hello
the function is placed in the EventHandlers.vbs file and is called by a rule.
I don't see anything out of the ordinary in the mail server log
Nothing appears in the error log.
The script should add notification that the attachment has been removed to the message. The attachment is successfully removed but the notification is not inserted
the function is placed in the EventHandlers.vbs file and is called by a rule.
I don't see anything out of the ordinary in the mail server log
Nothing appears in the error log.
The script should add notification that the attachment has been removed to the message. The attachment is successfully removed but the notification is not inserted
Re: Exclude attachment blocking for a domain name
This code allows creating a rule that calls the DeleteAttachments function on the account or general
block attachments only for a specific account or domain
This is the working version.
block attachments only for a specific account or domain
This is the working version.
Code: Select all
Sub DeleteAttachments(oMessage)
' this routine deletes or quarantines file attachments that have the specified
' FileExtensions. It replaces the functionality of antivirus blocked attachments panel in hmailadmin
' and also has a selectable quarantine option
Dim Quarantine ' set to True to Quarantine or False to Delete attachments
Quarantine = False
Dim QuarantineFolder 'where to store quarantined attachments. This folder must already exist.
QuarantineFolder = "c:\quarantine\" ' a slash bar is required
Dim QuarantineFile
Dim FileExtensions ' set to the file attachment extensions you want to delete or quarantine
FileExtensions = "(doc|docx|bat|cmd|com|cpl|csh|docm|exe|pif|hta|htb|inf|js|jse|lnk|msi|msp|pif|reg|scf|scr|shs|shb|vbe|vbs|wsf|wsh)"
' change anything below here at your own risk.
Dim AttachmentDeleteNotify
AttachmentDeleteNotify = Empty
Dim oAttachment
Dim oRegExp
Set oRegExp = new RegExp
For oAttachment = 0 to oMessage.Attachments.Count-1
' Verifica la presenza di allegati indesiderati
with oRegExp
.Pattern = "^.*\."& FileExtensions & "$"
.IgnoreCase = True
.Global = False
end with
if (oRegExp.test(oMessage.Attachments(oAttachment).Filename)) Then
' Elimina Allegati
AttachmentDeleteNotify = AttachmentDeleteNotify & oMessage.Attachments(oAttachment).Filename & " ;"
If (Quarantine) Then
QuarantineFile = QuarantineFolder & Left(Right(oMessage.Filename,42),38) _
& "." & oAttachment & "." & oMessage.Attachments(oAttachment).Filename & "." & ".Quarantined"
oMessage.Attachments(oAttachment).SaveAs(QuarantineFile)
oMessage.Attachments(oAttachment).Delete
Else
oMessage.Attachments(oAttachment).Delete
End If
End If
Next
' Adds a notification to the message
Set oRegExp = nothing
If Not IsEmpty(AttachmentDeleteNotify) then
AttachmentDeleteNotify = "------"&vbcrlf&"Alert:"&vbcrlf&"Some attachments deemed potentially dangerous have been deleted from this email."&vbcrlf&"If you are sure that the file is safe, you can ask the sender to compress it into a ZIP file. Then send it as an attachment."& vbcrlf & "Notice ID: " & Left(Right(oMessage.Filename,42),38) & vbcrlf &"Deleted Attachments: "& AttachmentDeleteNotify &vbcrlf&"Other files may have been deleted by the antivirus and notified in a text file attached to this message"& vbcrlf & "Admin Mail Server"& vbcrlf&"------"
oMessage.Body=oMessage.Body & vbcrlf & AttachmentDeleteNotify
if oMessage.HTMLBody <> "" then
AttachmentDeleteNotify=replace(AttachmentDeleteNotify,vbcrlf,"<br>")
oMessage.HTMLBody = oMessage.HTMLBody & "<br>" &AttachmentDeleteNotify
end if
oMessage.Save
End If
End Sub