interface Implements multi-user authentication system with email account management, profile settings, drive configuration, and security controls. Includes database migrations for user accounts, email credentials, preferences, and session management. Frontend provides intuitive UI for adding IMAP/SMTP accounts with provider presets and connection testing. Backend supports per-user vector databases for email and file indexing with Zitadel SSO integration and automatic workspace initialization. ```
6.9 KiB
Account Setup Quick Guide
🚀 Quick Start
Step 1: Run Database Migration
First, apply the new database migration to add user account tables:
cd botserver
diesel migration run
This creates the following tables:
user_email_accounts- Store email credentialsemail_drafts- Save email draftsemail_folders- Cache folder structureuser_preferences- User settingsuser_login_tokens- Session management
Step 2: Start the Server
Make sure the email feature is enabled (it should be by default):
cargo run --features email
Or if already built:
./target/release/botserver
Step 3: Access Account Settings
- Open your browser to
http://localhost:8080 - Click on the user avatar or settings icon
- Navigate to "Account Settings"
📧 Adding Your First Email Account
For Gmail Users
-
Generate App Password (Required for Gmail)
- Go to Google Account settings
- Security → 2-Step Verification
- App passwords → Generate new password
- Copy the 16-character password
-
Add Account in BotServer
- Go to Account Settings → Email Accounts tab
- Click "Add Account"
- Fill in:
Email: your-email@gmail.com Display Name: Your Name IMAP Server: imap.gmail.com IMAP Port: 993 SMTP Server: smtp.gmail.com SMTP Port: 587 Username: your-email@gmail.com Password: [paste app password] - Check "Set as primary email account"
- Click "Add Account"
-
Test Connection
- Click "Test" button
- Should show "Connection successful"
For Outlook/Office 365 Users
Email: your-email@outlook.com
IMAP Server: outlook.office365.com
IMAP Port: 993
SMTP Server: smtp.office365.com
SMTP Port: 587
Username: your-email@outlook.com
Password: [your password]
For Yahoo Mail Users
Important: Yahoo requires app-specific password
- Go to Yahoo Account Security
- Generate app password
- Use these settings:
Email: your-email@yahoo.com
IMAP Server: imap.mail.yahoo.com
IMAP Port: 993
SMTP Server: smtp.mail.yahoo.com
SMTP Port: 587
Username: your-email@yahoo.com
Password: [app-specific password]
For Custom IMAP/SMTP Servers
Email: your-email@domain.com
IMAP Server: mail.domain.com
IMAP Port: 993
SMTP Server: mail.domain.com
SMTP Port: 587
Username: your-email@domain.com (or just username)
Password: [your password]
📬 Using the Mail Client
Reading Emails
- Navigate to Mail section (📧 icon)
- Your emails will load automatically
- Click on any email to read it
- Use folders (Inbox, Sent, Drafts, etc.) to navigate
Sending Emails
- Click "Compose" button (✏️)
- Fill in:
- To: recipient@example.com
- Subject: Your subject
- Body: Your message
- Click "Send"
Multiple Accounts
If you have multiple email accounts:
- Account dropdown appears in mail toolbar
- Select account to view its emails
- Composing email uses currently selected account
🔧 Troubleshooting
"Failed to connect to IMAP server"
Possible causes:
- Incorrect server address or port
- Firewall blocking connection
- Need to enable IMAP in email provider settings
- Using regular password instead of app password
Solutions:
- Verify IMAP server address from your provider
- Check if IMAP is enabled in your email settings
- Use app-specific password for Gmail/Yahoo
- Try port 143 with STARTTLS if 993 fails
"Authentication failed"
Causes:
- Wrong username or password
- Need app-specific password
- 2FA not configured properly
Solutions:
- Double-check username (often full email address)
- Generate app-specific password
- Ensure 2FA is enabled before generating app password
"Failed to send email"
Causes:
- SMTP server/port incorrect
- Authentication issues
- Rate limiting
Solutions:
- Verify SMTP settings
- Try port 587 (STARTTLS) or 465 (SSL)
- Check if sender email matches account
- Wait and retry if rate limited
"No emails loading"
Causes:
- Mailbox is empty
- Wrong folder name
- IMAP connection issue
Solutions:
- Try different folders (INBOX, Sent)
- Click refresh button
- Test connection in Account Settings
- Check account is marked as active
🔒 Security Notes
Current Implementation
⚠️ IMPORTANT: Current password encryption uses base64 encoding, which is NOT SECURE for production use. This is temporary for development.
For Production Deployment
You MUST implement proper encryption before deploying to production:
-
Replace base64 with AES-256-GCM encryption
- Update
encrypt_password()anddecrypt_password()functions - Use a strong encryption key from environment variable
- Never commit encryption keys to version control
- Update
-
Use HTTPS/TLS
- All communication must be encrypted in transit
- Configure reverse proxy (nginx/Apache) with SSL certificate
-
Implement rate limiting
- Limit login attempts
- Limit email sending rate
- Protect against brute force attacks
-
Use JWT tokens for authentication
- Implement proper session management
- Token refresh mechanism
- Secure token storage
-
Regular security audits
- Review code for vulnerabilities
- Update dependencies
- Monitor for suspicious activity
📊 Account Management Features
Profile Settings
- Update display name
- Change phone number
- View account creation date
Security Settings
- Change password
- View active sessions
- Revoke sessions on other devices
Drive Settings
- View storage usage
- Configure auto-sync
- Enable offline mode
🆘 Getting Help
Check Logs
Server logs show detailed error messages:
# View recent logs
tail -f nohup.out
# Or if running in foreground
# Logs appear in terminal
API Testing
Test the API directly:
# List accounts
curl http://localhost:8080/api/email/accounts
# Add account
curl -X POST http://localhost:8080/api/email/accounts/add \
-H "Content-Type: application/json" \
-d '{"email":"test@gmail.com",...}'
Database Inspection
Check database directly:
psql -d botserver_dev -c "SELECT * FROM user_email_accounts;"
✅ Verification Checklist
- Database migration completed successfully
- Server starts with
emailfeature enabled - Can access Account Settings page
- Can add email account
- Connection test passes
- Can see emails in Mail client
- Can send email successfully
- Can compose and save drafts
- Multiple accounts work (if applicable)
📚 Further Reading
- See
MULTI_USER_SYSTEM.mdfor technical details - See
REST_API.mdfor API documentation - See
TESTING.mdfor testing procedures
🎯 Next Steps
After basic setup:
- Configure additional email accounts
- Explore Drive functionality
- Set up automated tasks (future)
- Customize preferences
- Implement proper security for production
Need help? Check the logs, review error messages, and consult the troubleshooting section above.