Jul 10 - Update codes to catch up with the single tenant project (Low)
This commit is contained in:
@@ -8,6 +8,7 @@ app/templates/billing/email/.
|
||||
|
||||
import logging
|
||||
import threading
|
||||
from urllib.parse import urlparse
|
||||
from flask import current_app, render_template
|
||||
from flask_mail import Message
|
||||
from app import mail
|
||||
@@ -91,6 +92,13 @@ def send_billing_email(to_addr: str, event_type: str, context_dict: dict):
|
||||
|
||||
app = current_app._get_current_object()
|
||||
|
||||
# Derive noreply sender from APP_BASE_URL so billing emails match the tenant domain.
|
||||
try:
|
||||
_netloc = urlparse(app.config.get('APP_BASE_URL', '')).netloc
|
||||
_sender = f'noreply@{_netloc}' if _netloc else app.config.get('MAIL_DEFAULT_SENDER', '')
|
||||
except Exception:
|
||||
_sender = app.config.get('MAIL_DEFAULT_SENDER', '')
|
||||
|
||||
def _send():
|
||||
try:
|
||||
with app.app_context():
|
||||
@@ -105,6 +113,7 @@ def send_billing_email(to_addr: str, event_type: str, context_dict: dict):
|
||||
msg = Message(
|
||||
subject=subject,
|
||||
recipients=[to_addr],
|
||||
sender=_sender or None,
|
||||
body=plain_body,
|
||||
html=html_body,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user