Email Settings
All email configuration is done through environment variables. These settings are required unless you disable email verification.SMTP server hostname.Examples:
- Gmail:
smtp.gmail.com - Outlook:
smtp.office365.com - SendGrid:
smtp.sendgrid.net - Mailgun:
smtp.mailgun.org
smtp.gmail.comSMTP server port. Common ports:
587- STARTTLS (recommended)465- SSL/TLS25- Plain (not recommended)
587Username for SMTP authentication. Usually your email address.Example:
[email protected]Password for SMTP authentication.Example:
your-app-passwordEmail address to use in the “From” field of sent emails.Example:
[email protected]Email Verification Control
Whether to skip email verification for new user registrations.When set to
True:- Users can log in immediately after registration
- No verification emails are sent
- Email fields are still validated but not verified
False:- Users must click a verification link sent to their email
- Users cannot log in until their email is verified
True or FalseConfiguration Examples
Email Templates
ClassQuiz sends two types of emails:Registration Verification Email
Sent when a new user registers. Contains a verification link that expires based on your token settings. Template location:classquiz/emails/templates/register.jinja2
Variables available:
base_url- Your ROOT_ADDRESStoken- Verification token
Password Reset Email
Sent when a user requests a password reset. The reset link expires after 1 hour (3600 seconds). Template location:classquiz/emails/templates/forgotten_password.jinja2
Variables available:
base_url- Your ROOT_ADDRESStoken- Password reset token
Email templates use Jinja2 templating. You can customize these templates by modifying the files in the
classquiz/emails/templates/ directory.Provider-Specific Setup
Gmail Setup
Gmail Setup
Generate App Password
- Go to Google Account Settings
- Navigate to Security → 2-Step Verification → App passwords
- Select “Mail” and “Other (Custom name)”
- Copy the 16-character password
SendGrid Setup
SendGrid Setup
Create API Key
- Log in to SendGrid
- Go to Settings → API Keys
- Create a new API key with “Mail Send” permissions
Custom SMTP Server
Custom SMTP Server
For self-hosted or custom SMTP servers:
- Ensure your SMTP server supports STARTTLS on port 587
- Create a dedicated email account for ClassQuiz
- Configure firewall rules to allow outbound connections on port 587
- Test with:
Testing Email Configuration
After configuring email settings, test the configuration by:Troubleshooting
Emails not being sent
Emails not being sent
Check that:
- All MAIL_* environment variables are set correctly
- SKIP_EMAIL_VERIFICATION is set to False
- Your SMTP server is reachable from the ClassQuiz container
- Firewall rules allow outbound connections on your MAIL_PORT
Authentication failed
Authentication failed
Common causes:
- Gmail: Using account password instead of App Password
- Office 365: Account has 2FA enabled without app-specific password
- Incorrect username or password
- Account locked due to suspicious activity
Emails going to spam
Emails going to spam
To improve email deliverability:
- Set up SPF, DKIM, and DMARC records for your domain
- Use a verified domain email address
- Use a reputable SMTP provider (SendGrid, Mailgun, etc.)
- Avoid generic words like “noreply” in the email address
SSL/TLS errors
SSL/TLS errors
ClassQuiz uses STARTTLS with SSL protocol TLS. If you encounter SSL errors:
- Ensure you’re using port 587 (not 465 or 25)
- Check if your SMTP server supports STARTTLS
- Verify SSL certificates are valid
ssl.PROTOCOL_TLS with starttls().Security Best Practices
- Use App Passwords or API keys instead of account passwords
- Restrict SMTP credentials to only send email (no read access)
- Use a dedicated email account for ClassQuiz
- Enable 2FA on your email account
- Regularly rotate SMTP passwords
- Monitor email sending logs for suspicious activity
Next Steps
Environment Variables
View all configuration options
OAuth Configuration
Set up social login providers