Skip to content

Commit 478e1de

Browse files
sanyo4evertalboren
andauthored
feat(mailgun): add custom domain support for self-hosted instances (#5362)
Signed-off-by: Tal <[email protected]> Co-authored-by: Tal <[email protected]>
1 parent 88fe695 commit 478e1de

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

keep/providers/mailgun_provider/mailgun_provider.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ class MailgunProviderAuthConfig:
3737
},
3838
default="",
3939
)
40+
email_domain: str = dataclasses.field(
41+
metadata={
42+
"required": False,
43+
"description": "Custom email domain for receiving alerts",
44+
"hint": "e.g., alerts.yourcompany.com (uses env MAILGUN_DOMAIN if not set)",
45+
"sensitive": False,
46+
},
47+
default="",
48+
)
4049
extraction: typing.Optional[list[dict[str, str]]] = dataclasses.field(
4150
default=None,
4251
metadata={
@@ -50,6 +59,7 @@ class MailgunProviderAuthConfig:
5059

5160
class MailgunProvider(BaseProvider):
5261
MAILGUN_API_KEY = os.environ.get("MAILGUN_API_KEY")
62+
MAILGUN_DOMAIN = os.environ.get("MAILGUN_DOMAIN", "mails.keephq.dev")
5363
WEBHOOK_INSTALLATION_REQUIRED = True
5464
PROVIDER_CATEGORY = ["Collaboration"]
5565

@@ -174,7 +184,13 @@ def setup_webhook(
174184
if not MailgunProvider.MAILGUN_API_KEY:
175185
raise Exception("MAILGUN_API_KEY is not set")
176186

177-
email = f"{tenant_id}-{self.provider_id}@mails.keephq.dev"
187+
# Use custom domain from config, env var, or default
188+
email_domain = (
189+
self.authentication_config.email_domain
190+
or MailgunProvider.MAILGUN_DOMAIN
191+
)
192+
193+
email = f"{tenant_id}-{self.provider_id}@{email_domain}"
178194
expression = f'match_recipient("{email}")'
179195

180196
if (

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "keep"
3-
version = "0.47.10"
3+
version = "0.47.11"
44
description = "Alerting. for developers, by developers."
55
authors = ["Keep Alerting LTD"]
66
packages = [{include = "keep"}]

0 commit comments

Comments
 (0)