mailpit icon indicating copy to clipboard operation
mailpit copied to clipboard

Documentation about tags

Open blackshot opened this issue 1 year ago • 3 comments

I'm currently trying to implement mailpit as a developer centralized mail sandbox for all my mails, in order to effectively do that i need to implement automatic tags, i made a yaml file as documentation says, it loads the tags but none of the emails are being tagged.

i couldn't find any documentation of how to build a matcher. even i tried to find it in source code but couldn't find anything.

EDIT: I somehow made it work using matcher "addressed:..." but "from:..." is not working.

blackshot avatar Jul 09 '24 21:07 blackshot

Hi @blackshot.

I cannot really make any comment without seeing the exact filter syntax you are using.

The following types of filter rules should work (you'll see both uses of addressed: and from: which work as expected for me):

filters:
  - match: addressed:[email protected]
    tags: Accounts
  - match: from:[email protected]
    tags: Github
  - match: from:@github.com subject:axllent/mailpit
    tags: Github, Mailpit

This is documented here. The match is exactly the same as you would use in the web UI to search/filter messages, which is documented here.

Edit: I wonder if it had to do with the quotes that were in the documentation (it had quotes around the match variables) ... it works perfectly fine for me without quotes (which I have now removed from the documentation).

axllent avatar Jul 09 '24 22:07 axllent

i just copied and pasted the documentation then removed the subject and addressed examples and left only the "from" example and changed the mail. didn't work, obviously i checked yaml syntax and enabled --verbose to check if it was loaded. it was.

could it be that "from" is in format "Name Surname" <[email protected]> ?

blackshot avatar Jul 09 '24 23:07 blackshot

Yes, that could be it. Please try your search first in the web UI to make sure it works we you would expect. I think in your case you probably want from:[email protected].

axllent avatar Jul 10 '24 04:07 axllent

Yes, that could be it. Please try your search first in the web UI to make sure it works we you would expect. I think in your case you probably want from:[email protected].

did exactly that and didn't work haha, i opted just to use "addressed:[email protected]" and controlling it by recipient which is working.

blackshot avatar Jul 17 '24 16:07 blackshot

Sorry, then I'm totally out of ideas as it's just guesswork here because I don't know the exact syntax you originally used in your yaml config, nor exactly what your email headers say. I realise the sensitivity of the information though (not to put it on GitHub etc).

Given that you have a working solution using addressed:, I'm going to close this issue as it doesn't look like something that can be solved unless I have all that information,. As I also mentioned earlier, I use from: and it is working for me, so I don't believe it is a bug either 👍

axllent avatar Jul 17 '24 19:07 axllent

Commenting in hopes that it will help others.

I encountered a similar issue in which none of my filters would work on a docker instance. I had previously set up this container and tried to add the MP_TAGS_CONFIG environment variable and configuration file afterward. Even after running a docker compose down and docker compose up, the tag filters were not loaded even though I verified the files were available within the container.

I had to docker compose down and then docker image rm axllent/mailpit before executing docker compose up again. It seems like the tags configuration MP_TAGS_CONFIG is only loaded on the first run of the container. With that said, I probably would have been fine by just running docker compose down and docker compose up --build --force-recreate.

bthall avatar Aug 16 '24 01:08 bthall

That is strange @bthall, and definitely not a limitation within Mailpit. Each time Mailpit restarts it will load whatever environment settings (or flags) are passed to it, and there should be no need to delete the docker image at all.

What may however be happening here is that when you docker compose up with an existing container it just starts the container with previously set variables? I'm not 100% sure though as I'm not a big user of docker compose (I use docker a lot though, but always delete the old container when redeploying). If this is the case then I do not think this is normal Docker (compose) behaviour either, unless you were using restart instead of down and then up.

The easy way to test is to log into your running docker container, assuming it's name is "mailpit": docker exec -it mailpit sh and then type env which will print out the current environment variables.

axllent avatar Aug 16 '24 03:08 axllent