July 7 - Fix reset link hasn't been sent 2

This commit is contained in:
2026-07-07 13:04:07 -04:00
parent 9b1f57769e
commit a10e314854
4 changed files with 15 additions and 80 deletions
+6 -3
View File
@@ -179,7 +179,6 @@ def _send_invite_email(user, token, base_url=None):
from flask import current_app, render_template_string
from flask_mail import Message
from app import mail
from urllib.parse import urlparse
import threading
if not current_app.config.get('MAIL_SERVER'):
@@ -189,8 +188,12 @@ def _send_invite_email(user, token, base_url=None):
effective_base = (base_url or current_app.config.get('APP_BASE_URL', '')).rstrip('/')
setup_link = f'{effective_base}{url_for("customers.set_password", token=token)}'
host = urlparse(effective_base).netloc or 'janitorialqc.local'
sender = f'noreply@{host}'
# From MUST be the authenticated SMTP identity (MAIL_DEFAULT_SENDER); a
# per-host noreply@<domain> is accepted by the relay but dropped downstream
# by SPF/DMARC. The per-domain host is still preserved in setup_link above.
sender = (current_app.config.get('MAIL_DEFAULT_SENDER')
or current_app.config.get('MAIL_USERNAME')
or 'noreply@janitorialqc.local')
html_body = render_template_string("""<!DOCTYPE html>
<html>