On 02 Nov 2016, at 21:45, vod vos <vod...@zoho.com> wrote: > HOW can we just receive just such as .jpg .png .mp4 and reject all other > attachment in a short regexp to do the job?
While you *CAN* do this (As Noel shows) you should not. Not only will you end up wit a maintenance nightmare, but you will always be dealing with rejected emails that (rightly) annoy your users. If your intent is to make your users hate your mail server and avoid it at all costs, go ahead. If you’d like to TEST this idea, then do what Noel suggests, but use /^Content-(Disposition|Type).*name\s*=/ WARN and check your logs for a month for the warnings so you get an idea of how many messages you’d be rejecting. You might also want to check existing mail. If you have a large enough store of email, something like this will show the types of extensions actually present: grep -Er -o “^Content-(Disposition|Type).*name\s*=\"[^\"]+" /path/to/lots/of/email | awk -F\" '{print $2}’ (and will probably also show some surprising results including images with no extensions at all)