[GH-ISSUE #69] Support for dynamic tags #45

Closed
opened 2026-03-15 12:16:31 +03:00 by kerem · 2 comments
Owner

Originally created by @ocean90 on GitHub (Mar 21, 2023).
Original GitHub issue: https://github.com/axllent/mailpit/issues/69

The tagging systems is really great! But currently it's a bit static as that you have to define the tags in advance.

My use case: Have a single Docker container for Mailpit and allow other (which are unknown before starting Mailpit) Docker containers via Traefik to use this Mailpit container to capture all emails. Now I'd like to have a tag which contains the source of the mail which is usually the host of the sender address. I'm calling this dynamic tags which could be defined with a regular expression like this:

--tag '$1=/@(.*)$/'

$1 would contain the matched group.

Does this make sense? Are tags the right thing for this since it seems like they apply to the whole message and not only a specific header?

Originally created by @ocean90 on GitHub (Mar 21, 2023). Original GitHub issue: https://github.com/axllent/mailpit/issues/69 The [tagging systems](https://github.com/axllent/mailpit/wiki/Tagging) is really great! But currently it's a bit static as that you have to define the tags in advance. My use case: Have a single Docker container for Mailpit and allow other (which are unknown before starting Mailpit) Docker containers via [Traefik](https://github.com/traefik/traefik) to use this Mailpit container to capture all emails. Now I'd like to have a tag which contains the source of the mail which is usually the host of the sender address. I'm calling this dynamic tags which could be defined with a regular expression like this: ``` --tag '$1=/@(.*)$/' ``` `$1` would contain the matched group. Does this make sense? Are tags the right thing for this since it seems like they apply to the whole message and not only a specific header?
kerem closed this issue 2026-03-15 12:16:36 +03:00
Author
Owner

@axllent commented on GitHub (Mar 21, 2023):

@ocean90 You are right, the tagging system is very "static" and quite limited, but this is somewhat intentional. Basically Mailpit was not originally designed with tagging in mind, not that it really changes the limitations. The automated tagging is done on a full body string match, and not limited to just the headers, nor does it support regular expressions. The thing is it won't / can't support regular expressions as one completely loses control of a) bad regex, and b) the matches - the result being that unsupported characters and potentially very long strings would get applied as tags and effectively break the UI. By pre-defining the tags Mailpit can at least validate the tag names at runtime, and display an error if invalid.

So the short answer is this isn't possible. The only solution I can think of is you finding a common string from each host (eg: an IP address of the host machine) and pre-defining your tags that way, for example --tag 'host1=1.2.3.4 host2=2.3.4.5'. Obviously those IP addresses would need to be in the message headers somewhere. Sorry, it's probably not the solution you were after, but it's the only solution I can think of. Does this make sense?

<!-- gh-comment-id:1478708670 --> @axllent commented on GitHub (Mar 21, 2023): @ocean90 You are right, the tagging system is very "static" and quite limited, but this is somewhat intentional. Basically Mailpit was not originally designed with tagging in mind, not that it really changes the limitations. The automated tagging is done on a full body string match, and not limited to just the headers, nor does it support regular expressions. The thing is it won't / can't support regular expressions as one completely loses control of a) bad regex, and b) the matches - the result being that unsupported characters and potentially very long strings would get applied as tags and effectively break the UI. By pre-defining the tags Mailpit can at least validate the tag names at runtime, and display an error if invalid. So the short answer is this isn't possible. The only solution I can think of is you finding a common string from each host (eg: an IP address of the host machine) and pre-defining your tags that way, for example `--tag 'host1=1.2.3.4 host2=2.3.4.5'`. Obviously those IP addresses would need to be in the message headers somewhere. Sorry, it's probably not the solution you were after, but it's the only solution I can think of. Does this make sense?
Author
Owner

@ocean90 commented on GitHub (Mar 22, 2023):

Thanks for the response! Definitely makes sense but I can't use it since the other containers are totally dynamic.

I guess what I'm really looking for is some sort of different inboxes based on the sender. I'm going to close this for now since it was just a nice-to-have but not important feature request.

<!-- gh-comment-id:1479851134 --> @ocean90 commented on GitHub (Mar 22, 2023): Thanks for the response! Definitely makes sense but I can't use it since the other containers are totally dynamic. I guess what I'm really looking for is some sort of different inboxes based on the sender. I'm going to close this for now since it was just a nice-to-have but not important feature request.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#45
No description provided.