first commit
This commit is contained in:
61
server/utils/welcome_email.py
Normal file
61
server/utils/welcome_email.py
Normal file
@@ -0,0 +1,61 @@
|
||||
import os
|
||||
import logging
|
||||
from utils.email import send_gmail_with_attachment
|
||||
|
||||
|
||||
class WelcomeMessage:
|
||||
"""
|
||||
Sends a welcome email with an optional attached user manual (PDF).
|
||||
|
||||
- Looks for the manual in SERVER_ASSETS_DIR (env) or defaults to ../assets next to this file.
|
||||
- Manual filename can be customized with WELCOME_MANUAL_FILENAME (env), default: manual.pdf.
|
||||
"""
|
||||
|
||||
def __init__(self, email: str):
|
||||
self.email = email
|
||||
self.subject = "Bine ati venit!"
|
||||
|
||||
# Allow overriding assets folder and manual filename via env for containerized deployments.
|
||||
default_assets = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "assets"))
|
||||
self.assets_folder = os.getenv("SERVER_ASSETS_DIR", default_assets)
|
||||
self.manual_filename = os.getenv("WELCOME_MANUAL_FILENAME", "Manual.pdf")
|
||||
self.manual = os.path.join(self.assets_folder, self.manual_filename)
|
||||
|
||||
logging.info("WelcomeMessage assets dir: %s", self.assets_folder)
|
||||
logging.info("WelcomeMessage manual path: %s", self.manual)
|
||||
|
||||
self.body = f"""
|
||||
|
||||
Stimate/ă domn/ă,
|
||||
|
||||
Ne face plăcere să vă urăm bun venit la JuridicBloc. Vă mulțumim că ați ales platforma noastră pentru a vă susține nevoile administratiei.
|
||||
|
||||
Pentru a vă ajuta să începeți, am atașat Manualul de utilizare la acest e-mail. Acesta oferă instrucțiuni pas cu pas privind configurarea contului, o prezentare generală a funcțiilor și cele mai bune practici pentru utilizarea eficientă a aplicatiei JuridicBloc.
|
||||
|
||||
Vă recomandăm să consultați manualul atunci când vă este convenabil pentru a vă familiariza cu capacitățile sistemului. Dacă aveți nevoie de asistență suplimentară, echipa noastră de asistență este disponibilă la adresa support@juridicbloc.ro.
|
||||
|
||||
Așteptăm cu nerăbdare să vă susținem succesul și să construim un parteneriat pe termen lung.
|
||||
|
||||
Cu sinceritate,
|
||||
Echipa JuridicBloc
|
||||
|
||||
"""
|
||||
|
||||
def send_email(self):
|
||||
# If the manual exists, send with attachment; otherwise, log and send nothing (or integrate a no-attachment sender later).
|
||||
if os.path.isfile(self.manual):
|
||||
send_gmail_with_attachment(
|
||||
to_email=self.email,
|
||||
subject=self.subject,
|
||||
body=self.body,
|
||||
attachment_path=self.manual,
|
||||
)
|
||||
else:
|
||||
logging.warning(
|
||||
f"Welcome manual missing, skipping attachment. Looked at: {self.manual} "
|
||||
f"(set SERVER_ASSETS_DIR or WELCOME_MANUAL_FILENAME to adjust). "
|
||||
f"Current working directory: {os.getcwd()}"
|
||||
)
|
||||
# If you later implement send_gmail() without attachment, call it here.
|
||||
# from utils.email import send_gmail
|
||||
# send_gmail(to_email=self.email, subject=self.subject, body=self.body)
|
||||
Reference in New Issue
Block a user