Spaces:
Sleeping
Sleeping
Email Configuration Guide for AIMHSA
Current Status
The email service is not configured, which is why you're seeing the error:
ERROR in app: Failed to send email: Email service not configured
How to Configure Email Service
Option 1: Gmail (Recommended)
- Create a
.envfile in your project root directory - Add the following configuration:
# Gmail SMTP Configuration
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=your-email@gmail.com
SMTP_PASSWORD=your-app-password
FROM_EMAIL=noreply@aimhsa.rw
- Get Gmail App Password:
- Go to your Google Account settings
- Enable 2-Factor Authentication
- Generate an "App Password" for this application
- Use the 16-character app password (not your regular password)
Option 2: Outlook/Hotmail
SMTP_SERVER=smtp-mail.outlook.com
SMTP_PORT=587
SMTP_USERNAME=your-email@outlook.com
SMTP_PASSWORD=your-password
FROM_EMAIL=noreply@aimhsa.rw
Option 3: Yahoo Mail
SMTP_SERVER=smtp.mail.yahoo.com
SMTP_PORT=587
SMTP_USERNAME=your-email@yahoo.com
SMTP_PASSWORD=your-app-password
FROM_EMAIL=noreply@aimhsa.rw
Option 4: Custom SMTP Server
SMTP_SERVER=your-smtp-server.com
SMTP_PORT=587
SMTP_USERNAME=your-username
SMTP_PASSWORD=your-password
FROM_EMAIL=noreply@aimhsa.rw
Testing Email Configuration
After creating the .env file:
- Restart your Flask application
- Test the forgot password functionality
- Check the logs for email sending status
Current Behavior (Without Email Configuration)
- ✅ Forgot password still works - returns reset token in response
- ✅ Password reset functionality works - you can use the token manually
- ❌ No actual emails sent - token is displayed in the UI for testing
Security Notes
- Never commit
.envfiles to version control - Use app passwords instead of regular passwords for Gmail
- Keep email credentials secure
- Consider using environment variables in production
Troubleshooting
Common Issues:
- "Authentication failed" - Check username/password
- "Connection refused" - Check SMTP server and port
- "App password required" - Enable 2FA and generate app password
- "Less secure app access" - Use app passwords instead
Test Email Configuration:
# Test with curl
curl -X POST https://prodevroger-ishingiro.hf.space/forgot_password \
-H "Content-Type: application/json" \
-d '{"email": "test@example.com"}'