From b2004bb5ec1b8c5c8bf71ce962a9a93b3cf0749f Mon Sep 17 00:00:00 2001 From: "Troll (Hermes Agent)" Date: Sat, 1 Aug 2026 23:06:19 +0000 Subject: [PATCH] Add confirmation email, logo + tagline signature on all customer emails --- app.py | 62 +++++++++++++++++++++++++++++++++++++++++++--- example-email.html | 37 +++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 example-email.html diff --git a/app.py b/app.py index 270dd59..25441bb 100644 --- a/app.py +++ b/app.py @@ -214,13 +214,14 @@ def save_booth_settings(settings): flash(f'Warning: could not save settings: {e}', 'error') -def send_email(to, subject, body, attachments=None): +def send_email(to, subject, body, attachments=None, inline_images=None): """ - Send an email via SMTP_SSL. + Send an email via SMTP using credentials from the app config. :param to: recipient address :param subject: email subject :param body: plain-text body :param attachments: optional list of (filepath, attachment_name) tuples + :param inline_images: optional list of (filepath, cid) tuples for inline images """ cfg = current_app.config if not cfg['SMTP_PASS']: @@ -232,6 +233,25 @@ def send_email(to, subject, body, attachments=None): msg['Subject'] = subject msg.set_content(body) + # Build HTML version of the email with the same body and optional inline images. + html_body = body.replace('\n', '
\n') + if inline_images: + for _, cid in inline_images: + html_body += f'
Dionysis Media' + html_body += f'


Dionysis Media: stories, sound, and a little divine chaos — https://dionysismedia.ca/

' + msg.add_alternative(html_body, subtype='html') + + # Attach inline images for HTML rendering. + if inline_images: + for path, cid in inline_images: + with open(path, 'rb') as f: + data = f.read() + # Guess subtype from extension. + ext = Path(path).suffix.lower().lstrip('.') + maintype = 'image' + subtype = ext if ext in ('png', 'jpg', 'jpeg', 'gif', 'webp') else 'png' + msg.get_payload()[1].add_related(data, maintype=maintype, subtype=subtype, cid=f'<{cid}>') + # Attach any MP3 files as audio/mpeg attachments. if attachments: for path, name in attachments: @@ -244,6 +264,13 @@ def send_email(to, subject, body, attachments=None): server.send_message(msg) +def build_signature_images(): + """Return inline image tuple list for the Dionysis Media logo if present.""" + logo_path = Path('/mnt/Storage/DM-Logo.png') + if logo_path.exists(): + return [(str(logo_path), 'dm-logo')] + return [] + # --------------------------------------------------------------------------- # Public customer routes # --------------------------------------------------------------------------- @@ -272,6 +299,33 @@ def request_form(): extra_requests=request.form.get('extra_requests', '').strip(), vocal_gender=request.form.get('vocal_gender', '').strip(), ) + + # Send confirmation email with a summary of what the customer asked for. + req = get_request_by_id(rid) + if req: + try: + body_lines = [ + f"Hi {req['name']},", + "", + "Thanks for stopping by the Trollgorithm Theme Song Booth! We've received your request and will start crafting your custom song soon.", + "", + "Here's what we have on file:", + f"Name: {req['name']}", + f"Email: {req['email']}", + f"Style / genre: {req['style_genre'] or '-'}", + f"Preferred singer voice / gender: {req['vocal_gender'] or 'No preference'}", + f"Hobbies: {req['hobbies'] or '-'}", + f"Notable facts: {req['notable_facts'] or '-'}", + f"Extra requests: {req['extra_requests'] or '-'}", + "", + "You'll get another email with a private link to preview two versions of your song when they're ready.", + "", + "— Trollgorithm / Dionysis Media" + ] + send_email(req['email'], 'Your theme song request is received', '\n'.join(body_lines), inline_images=build_signature_images()) + except Exception as e: + flash(f'Your request was saved, but we could not send a confirmation email: {e}', 'error') + flash('Your request has been submitted! Check your email soon.', 'success') return redirect(url_for('thanks', rid=rid)) return render_template('request.html') @@ -495,7 +549,7 @@ def admin_request(rid): player_link = f"{current_app.config['PUBLIC_BASE_URL']}/play/{req['player_token']}" body = f"Hi {req['name']},\n\nYour custom theme song has been created. Listen to both versions and let us know which one you want:\n\n{player_link}\n\n- Version A\n- Version B\n- Or both versions\n\nOnce you make your choice, we'll send you to the booth to finalize payment and deliver your files.\n\nThanks for stopping by!\n\n— {current_app.config['BOOTH_NAME']}" try: - send_email(req['email'], 'Your custom theme song is ready — listen and pick your version', body) + send_email(req['email'], 'Your custom theme song is ready — listen and pick your version', body, inline_images=build_signature_images()) update_request(rid, preview_sent_at=now_utc(), status='songs_uploaded') flash('Preview email sent.', 'success') except Exception as e: @@ -523,7 +577,7 @@ def admin_request(rid): player_link = f"{current_app.config['PUBLIC_BASE_URL']}/play/{req['player_token']}" body = f"Hi {req['name']},\n\nThanks for your payment! Your selected song(s) are attached to this email.\n\nYou can also keep streaming them here: {player_link}\n\nEnjoy!\n\n— {current_app.config['BOOTH_NAME']}" try: - send_email(req['email'], 'Your theme song files are here!', body, attachments=attachments) + send_email(req['email'], 'Your theme song files are here!', body, attachments=attachments, inline_images=build_signature_images()) update_request(rid, square_payment_ref=payment_ref, delivery_sent_at=now_utc(), status='delivered') flash('Delivery email sent with MP3 attachments.', 'success') except Exception as e: diff --git a/example-email.html b/example-email.html new file mode 100644 index 0000000..34aa9e4 --- /dev/null +++ b/example-email.html @@ -0,0 +1,37 @@ + + + + + + +
+

Your theme song request is received

+

Hi Craig,

+

Thanks for stopping by the Trollgorithm Theme Song Booth! We've received your request and will start crafting your custom song soon.

+

Here's what we have on file:

+ +

You'll get another email with a private link to preview two versions of your song when they're ready.

+

— Trollgorithm / Dionysis Media

+
+ +
+ + \ No newline at end of file