# 📧 Email Setup Guide for National Medlab Cooperative

## 🔍 **Current Issue**
You're seeing "Email verification could not be sent" because email settings need to be configured.

---

## 🛠️ **QUICK SOLUTIONS**

### **Option 1: Manual Verification (Immediate Fix)**
1. After registration, you'll see a blue message with a verification link
2. Click the "click here to verify manually" link
3. Your account will be verified instantly
4. You can then login normally

### **Option 2: Configure Gmail SMTP (Recommended)**
1. **Enable 2-Factor Authentication** on your Gmail account
2. **Generate App Password**:
   - Go to Google Account settings
   - Security → 2-Step Verification → App passwords
   - Generate new app password
3. **Update .env file**:
   ```
   MAIL_USERNAME=your_gmail@gmail.com
   MAIL_PASSWORD=your_16_character_app_password
   ```

### **Option 3: Use Development Email Service**
1. **Create a temporary Gmail account** for testing
2. **Use these settings**:
   ```
   MAIL_USERNAME=nationalmedlabcoop@gmail.com
   MAIL_PASSWORD=your_app_password_here
   ```

---

## 🔧 **STEPS TO FIX EMAIL**

### **Step 1: Get Gmail App Password**
1. Go to: https://myaccount.google.com/
2. Security → 2-Step Verification
3. App passwords → Generate new
4. Select "Mail" on device "Other (Custom name)"
5. Copy the 16-character password

### **Step 2: Update Configuration**
Edit the `.env` file in your project folder:
```
MAIL_USERNAME=your_gmail@gmail.com
MAIL_PASSWORD=xxxx-xxxx-xxxx-xxxx
```

### **Step 3: Restart Application**
```bash
python app.py
```

---

## 🚀 **ALTERNATIVE: Skip Email for Development**

For immediate testing without email setup:

1. Register a new user
2. Click the manual verification link in the blue message
3. Account will be verified instantly
4. Login and test all features

---

## 📧 **Test Email Settings**

To verify email is working:
1. Register a test user
2. Check if you receive verification email
3. If yes, email is configured correctly!

---

## 🔒 **Security Notes**

- **Never commit** your `.env` file to version control
- **Use app passwords**, not your regular Gmail password
- **For production**, use a dedicated email service
- **Consider** using SendGrid or Mailgun for production

---

## 🆘 **Troubleshooting**

### **"SMTPAuthenticationError"**
- Check Gmail username and app password
- Ensure 2-factor authentication is enabled

### **"Connection refused"**
- Check internet connection
- Verify SMTP settings (port 587, TLS enabled)

### **"Email not received"**
- Check spam folder
- Verify sender email address
- Test with different email provider

---

**🎉 For immediate testing, use the manual verification link option!**
