From 85a0640fd5f761ed2bc195c946ce0ddb1b9881f6 Mon Sep 17 00:00:00 2001 From: jedi Date: Fri, 8 Nov 2024 21:06:55 +0100 Subject: [PATCH] add mailpit to docker-compose --- core/core/settings.py | 4 +++- core/mail/protocol.py | 4 +++- deploy/testing/docker-compose.yml | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/core/settings.py b/core/core/settings.py index 5b37ad8..518f425 100644 --- a/core/core/settings.py +++ b/core/core/settings.py @@ -210,9 +210,11 @@ CHANNEL_LAYERS = { 'hosts': [(os.getenv('REDIS_HOST', 'localhost'), 6379)], }, } - } +SMTP_GATEWAY_HOST = os.getenv('SMTP_GATEWAY_HOST', 'localhost') +SMTP_GATEWAY_PORT = int(os.getenv('SMTP_GATEWAY_PORT', '25')) + PROMETHEUS_METRIC_NAMESPACE = 'c3lf' TEST_RUNNER = 'core.test_runner.FastTestRunner' diff --git a/core/mail/protocol.py b/core/mail/protocol.py index a87f1a6..635766b 100644 --- a/core/mail/protocol.py +++ b/core/mail/protocol.py @@ -10,6 +10,8 @@ from mail.models import Email, EventAddress, EmailAttachment from notify_sessions.models import SystemEvent from tickets.models import IssueThread +from core.settings import SMTP_GATEWAY_HOST, SMTP_GATEWAY_PORT + class SpecialMailException(Exception): pass @@ -88,7 +90,7 @@ def make_reply(reply_email, references=None, event=None): async def send_smtp(message): - await aiosmtplib.send(message, hostname="127.0.0.1", port=25, use_tls=False, start_tls=False) + await aiosmtplib.send(message, hostname=SMTP_GATEWAY_HOST, port=SMTP_GATEWAY_PORT, use_tls=False, start_tls=False) def find_active_issue_thread(in_reply_to, address, subject): diff --git a/deploy/testing/docker-compose.yml b/deploy/testing/docker-compose.yml index e93e901..8a7df09 100644 --- a/deploy/testing/docker-compose.yml +++ b/deploy/testing/docker-compose.yml @@ -16,6 +16,12 @@ services: ports: - "3306:3306" + mailpit: + image: axllent/mailpit + ports: + - "8025:8025" + - "1025:1025" + core: build: context: ../../core