Add SMTP test email button and recipient field on settings page
This commit is contained in:
parent
fb779248ea
commit
48db5c5461
2 changed files with 24 additions and 0 deletions
14
app.py
14
app.py
|
|
@ -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()
|
||||
|
|
|
|||
Reference in a new issue