Add SMTP test email button and recipient field on settings page

This commit is contained in:
Troll (Hermes Agent) 2026-08-01 23:24:33 +00:00
parent fb779248ea
commit 48db5c5461
2 changed files with 24 additions and 0 deletions

14
app.py
View file

@ -806,6 +806,20 @@ def admin_settings():
flash('Email (SMTP) settings saved. Password stored encrypted.', 'success')
return redirect(url_for('admin_settings'))
elif action == 'send_test_email':
# Send a test email to the address provided in the form.
test_to = request.form.get('test_email_address', '').strip()
if not test_to:
flash('Enter a test email address first.', 'error')
return redirect(url_for('admin_settings'))
try:
body = "Hi,\n\nThis is a test email from the Trollgorithm Theme Song Booth. If you're seeing this, SMTP is configured correctly."
send_email(test_to, 'SMTP Test from Theme Song Booth', body, inline_images=build_signature_images())
flash(f'Test email sent to {test_to}.', 'success')
except Exception as e:
flash(f'Failed to send test email: {e}', 'error')
return redirect(url_for('admin_settings'))
elif action == 'save_refresh':
# Update dashboard auto-refresh interval.
val = request.form.get('refresh_seconds', '10').strip()

View file

@ -266,6 +266,16 @@
</table>
<button type="submit">Save Email Settings</button>
</form>
<hr style="border:none;border-top:1px solid var(--border);margin:1.5rem 0;">
<h3>Send Test Email</h3>
<form method="POST">
<input type="hidden" name="action" value="send_test_email">
<label for="test_email_address">Test recipient address</label>
<input type="email" id="test_email_address" name="test_email_address" placeholder="you@example.com" required>
<button type="submit">Send Test Email</button>
</form>
</div>
<!-- MP3 metadata defaults -->