Archiving Rules - Attachment Type example

Issue #192 resolved
Clemo created an issue

Please guide me on how to add a regex for "Attachment Type" for Archiving rules. I am not familiar with regex at all (leave alone TRE), and I notice that in the documentation there is no example for laymen like us for Attachment Type.

I have tried to simply add attachment types by entering, e.g., "exe", and also ".exe", but when I do that, Piler rejects all mails, including those without any rules set for them. I guess am doing something wrong here.

Regards,

Clemo

p.s. Am using latest master branch

Comments (7)

  1. Janos SUTO repo owner

    It seems that you are trying to match the attachment name against the attachment type. eg. you want to check for "exe" while piler sees eg. application/octet-stream.

    Anyway you can test your rules with pilertest, eg. run pilertest /path/to/message.eml, and it will show if it matches against a certain rule.

    However if you really want to check for attachment names (and not types), then I may extend the rule checking feature.

  2. Clemo reporter

    Let me give an example to cross-check if we are on the same page, For example I want to ask Piler not to archive any .jpg or .jpeg attachments (assuming I dont want to archive photos). So any mail with that attachment should will be affected. Is this an Attachment name or Attachment type ? (Second question comes up, if this works, would Piler block the whole mail or strip only the attachment ?).

    As explained in my earlier post, when I insert .jpeg, for instance under Attachment type, all mails are rejected.

  3. Janos SUTO repo owner

    You can solve this task in 2 ways:

    check the attachment type for images. For my emails I can search for image/jpeg, image/gif and image/png. So to block all emails having an image attachment, then you may specify simply "image/".

    Note that if an archiving rule is matched then piler will discard the whole email, so it won't strip the problematic attachment, then archive the rest.

    The other option (just tested on the demo site, so it's not published yet) can be a check for the filename. Probably you wanted to exclude any file ending with an .exe, so probably ".exe$" may do the trick. However in this case be sure to check for tricky names with multiple extensions, eg. demo-file.doc.exe or the opposite: demo-file.exe.doc. (Not sure which way to fool some windows applications to open the wrong extension).

    And before clicking on the "apply changes" button, be sure to test the rule with pilertest.

    So which way do you want to check for exe files?

  4. Clemo reporter

    From my tests, matching by filenames appears to be more preferable. It seems more accurate to match, e.g. against a file called "test.exe" than type which matches it as application/octet-stream (this is rather general).

    But it seems there is a need to extend the rule checking features since there is no option for checking them under filename.

  5. Janos SUTO repo owner

    OK, understood. I'll commit soon the changes allowing you to specify attachment filename patterns.

  6. Janos SUTO repo owner

    OK, I've just committed the new feature. So please download the master branch, and update both the binaries and the gui.

    Make sure to check out util/db-upgrade-0.1.24-vs-0.1.25.sql, as the database scheme is changed.

  7. Log in to comment