File size: 2,517 Bytes
c024705
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eeacc46
c024705
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# 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)

1. **Create a `.env` file** in your project root directory
2. **Add the following configuration:**

```env
# 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
```

3. **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

```env
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

```env
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

```env
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:

1. **Restart your Flask application**
2. **Test the forgot password functionality**
3. **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 `.env` files** 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:

1. **"Authentication failed"** - Check username/password
2. **"Connection refused"** - Check SMTP server and port
3. **"App password required"** - Enable 2FA and generate app password
4. **"Less secure app access"** - Use app passwords instead

### Test Email Configuration:

```bash
# Test with curl
curl -X POST https://prodevroger-ishingiro.hf.space/forgot_password \
  -H "Content-Type: application/json" \
  -d '{"email": "test@example.com"}'
```