11-13-2007 12:15 AM
Hi there,
I have had a search through the forum, however could not find an answer.
We have a series of C300 Appliances and as part of our Mail Policy we would like to detect and restrict the number of attachments sent on an email. For example if someone sends an email and it has 4 attachments (of any type or size, we have another policy for restricting file size) attached we will let it through, however if they attach 5 or more attachments we would like to either quarantine it or send it though with a warning message.
Is this currently possible? If not, how can we request this to be added?
Thanks,
David
11-13-2007 01:12 PM
I dug this out of an internal thread on this:
You can use the $filesizes variable to do a regex against if you only need to enforce a maximum number of attachments. I use $filesizes instead of $filenames so you cant have a false positive on ", " in the filename.
Note: You need to use the insert-header command since we cant match directly against variables.
RestrictOneAttachment:
if (true) {
insert-header("X-Filesizes", "$filesizes");
if (header("X-Filesizes") == ", ") {
drop();
}
strip-header("X-Filesizes");
}
This will drop a message with more than one attachment. For a specific number, Ex. if there is more than 2 attachments.
if (header("X-Filesizes") == "(, \\d+){2,}") ^^ this will match against an email with 3 or more attachments.
Good luck.....sounds like a feature request to have this as a filter rule for the future :wink:
11-13-2007 08:30 PM
Thank you, verylongbloke!
I'm very interested in such a solution too. Could you please give me some more informations where exactly I have to fill in your code and where I can change the message back to the sender with a text like "...please create one ZIP-Archive with your multiple attachments..."
11-13-2007 10:36 PM
Thanks for the info.
Is there a way to have it quarantine or forward with a Notification rather than dropping it?
How do we put this request on the future features list?
Edit: I just spoke to my local Ironport Support person and they said it is already on the Feature Request list. I guess we just need to wait for it to happen :)
Regards,
David
11-14-2007 10:08 PM
Thanks for the info.
Is there a way to have it quarantine or forward with a Notification rather than dropping it?
11-14-2007 11:00 PM
Hi Shane,
Yep, I have seen and done that with other filters. I was hoping to be able to do it with the code that verylongbloke posted up. He said that it would only drop the message.
I am happy to wait for the new filter to be added. Hope it is not too long away ;)
Regards,
David
11-14-2007 11:51 PM
Hi Shane,
Yep, I have seen and done that with other filters. I was hoping to be able to do it with the code that verylongbloke posted up. He said that it would only drop the message.
I am happy to wait for the new filter to be added. Hope it is not too long away ;)
Regards,
David
11-15-2007 01:33 AM
Thanks for the extra info.
I have modified the code as below
Restrict10Attachment:
if (true)
{
insert-header("X-Filesizes", "$filesizes");
if (header("X-Filesizes") == "(, \\d+){10,}")
{
notify("$Envelopesender","legal.restricted.out");
quarantine("Prohibited");
}
strip-header("X-Filesizes");
}
If I read it right, it should check for 10 or more attachments, notify the sender, and use the Notify Template I have called "legal.restricted.out"
I am going use this filter for all mail entering and leaving the company, so have not included the "if(recv-listener=="Outboundlistener")" line.
Regards,
David
11-15-2007 04:32 AM
OK I have been testing this for most of the day and have the following script
Restrict10Attachment:
if (true)
{
insert-header("X-Filesizes", "$filesizes");
if (header("X-Filesizes") == "(, \\d+){10,}")
{
notify("$Envelopefrom", "[$FilterName] Too many Attachments", "$Envelopesender",
"legal.numberofattachments");
quarantine("Prohibited");
}
strip-header("X-Filesizes");
}
It detects the email has more than 10 attachments and places it into the Prohibited quarantine area, and then notifies the sender, the only problem is when the email is sent to the sender it apears to have come from themselves. What have I done wrong? and how can I make it apear to come from an email address I specify, eg: noreply@mycompany.com
Thanks,
David
11-15-2007 09:37 AM
Sorry - forgot to look at this thread this sooner..
notify("$Envelopefrom", "[$FilterName] Too many Attachments", "$Envelopesender", "legal.numberofattachments");
The manual for v5.5 adv user guide states:
The notify action also supports up to three additional, optional arguments that allow you to specify after the email address; the subject header, the Envelope Sender, and a pre-defined text resource to use for the notification message. These parameters must appear in order, so a subject must be provided if the Envelope Sender is to be set or a notification template specified.
Your action should change to (i think):
notify("$Envelopefrom", "[$FilterName] Too many Attachments", noreply@mycompany.com", "legal.numberofattachments");
That should do the trick i think....
11-15-2007 10:51 PM
That did the trick. Thankyou very much :)
David
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide