Email COnfigs & setup
This commit is contained in:
@@ -325,25 +325,113 @@ Config (JSON):
|
||||
|
||||
4. Click **"Save"**
|
||||
|
||||
### 5.3 Testing Email Delivery
|
||||
### 5.3 Email Settings Management
|
||||
|
||||
After configuring Resend, test email delivery:
|
||||
IGNY8 provides a dedicated **Email Settings** navigation group in Django Admin:
|
||||
|
||||
| Menu Item | URL | Purpose |
|
||||
|-----------|-----|---------|
|
||||
| Email Configuration | `/admin/system/emailsettings/` | Global email defaults (from, reply-to, feature flags) |
|
||||
| Email Templates | `/admin/system/emailtemplate/` | Manage/test email templates |
|
||||
| Email Logs | `/admin/system/emaillog/` | View sent email history |
|
||||
| Resend Provider | `/admin/system/integrationprovider/resend/change/` | API key & config |
|
||||
|
||||
**Email Configuration Settings:**
|
||||
- `from_email` - Default sender (must be verified in Resend)
|
||||
- `from_name` - Display name for sender
|
||||
- `reply_to_email` - Reply-to address
|
||||
- `send_welcome_emails` - Toggle welcome emails on/off
|
||||
- `send_billing_emails` - Toggle payment/invoice emails
|
||||
- `send_subscription_emails` - Toggle renewal reminders
|
||||
- `low_credit_threshold` - Credits level to trigger warning email
|
||||
|
||||
### 5.4 Testing Email Delivery
|
||||
|
||||
**Method 1: Django Admin UI (Recommended)**
|
||||
|
||||
1. Go to **Email Settings → Email Templates**
|
||||
2. Click the **"Test"** button next to any template
|
||||
3. Enter recipient email and customize context JSON
|
||||
4. Click **"Send Test Email"**
|
||||
5. Check **Email Logs** to verify delivery
|
||||
|
||||
**Method 2: Command Line (Docker)**
|
||||
|
||||
```bash
|
||||
cd /data/app/igny8/backend
|
||||
python manage.py shell
|
||||
```
|
||||
|
||||
```python
|
||||
docker exec -it igny8_backend python manage.py shell -c "
|
||||
from igny8_core.business.billing.services.email_service import get_email_service
|
||||
|
||||
service = get_email_service()
|
||||
service.send_transactional(
|
||||
result = service.send_transactional(
|
||||
to='your-email@example.com',
|
||||
subject='Test Email from IGNY8',
|
||||
html='<h1>Test Email</h1><p>If you receive this, Resend is configured correctly!</p>',
|
||||
text='Test Email. If you receive this, Resend is configured correctly!'
|
||||
)
|
||||
print('Result:', result)
|
||||
"
|
||||
```
|
||||
|
||||
**Expected successful response:**
|
||||
```python
|
||||
{'success': True, 'id': '81193754-6f27-4b1a-9c36-d83ae18f6a9a', 'provider': 'resend'}
|
||||
```
|
||||
|
||||
**Method 3: Test with Template**
|
||||
|
||||
```bash
|
||||
docker exec -it igny8_backend python manage.py shell -c "
|
||||
from igny8_core.business.billing.services.email_service import get_email_service
|
||||
|
||||
service = get_email_service()
|
||||
result = service.send_transactional(
|
||||
to='your-email@example.com',
|
||||
subject='Welcome Test',
|
||||
template='emails/welcome.html',
|
||||
context={
|
||||
'user_name': 'Test User',
|
||||
'account_name': 'Test Account',
|
||||
'login_url': 'https://app.igny8.com/login',
|
||||
'frontend_url': 'https://app.igny8.com',
|
||||
},
|
||||
tags=['test']
|
||||
)
|
||||
print('Result:', result)
|
||||
"
|
||||
```
|
||||
|
||||
### 5.5 Available Email Templates
|
||||
|
||||
| Template | Type | Trigger |
|
||||
|----------|------|---------|
|
||||
| `welcome` | Auth | User registration |
|
||||
| `password_reset` | Auth | Password reset request |
|
||||
| `email_verification` | Auth | Email verification |
|
||||
| `payment_confirmation` | Billing | Manual payment submitted |
|
||||
| `payment_approved` | Billing | Payment approved |
|
||||
| `payment_rejected` | Billing | Payment declined |
|
||||
| `payment_failed` | Billing | Auto-payment failed |
|
||||
| `subscription_activated` | Billing | Subscription activated |
|
||||
| `subscription_renewal` | Billing | Renewal reminder |
|
||||
| `refund_notification` | Billing | Refund processed |
|
||||
| `low_credits` | Notification | Credits below threshold |
|
||||
|
||||
### 5.6 Email Service API Reference
|
||||
|
||||
```python
|
||||
send_transactional(
|
||||
to: str | List[str], # Required: recipient email(s)
|
||||
subject: str, # Required: email subject
|
||||
html: str = None, # HTML content
|
||||
text: str = None, # Plain text content
|
||||
template: str = None, # Template path (e.g., 'emails/welcome.html')
|
||||
context: dict = None, # Template context variables
|
||||
from_email: str = None, # Override sender email
|
||||
from_name: str = None, # Override sender name
|
||||
reply_to: str = None, # Reply-to address
|
||||
attachments: List = None, # File attachments
|
||||
tags: List[str] = None # Email tags for tracking
|
||||
)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user