2025-06-07 10:48:03 +01:00
|
|
|
{% extends "base.html" %}
|
|
|
|
|
|
2025-06-08 11:13:43 +01:00
|
|
|
{% block title %}Add Sender - Email Server{% endblock %}
|
2025-06-07 10:48:03 +01:00
|
|
|
|
|
|
|
|
{% block content %}
|
|
|
|
|
<div class="container-fluid">
|
|
|
|
|
<div class="row">
|
|
|
|
|
<div class="col-md-8 mx-auto">
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="card-header">
|
|
|
|
|
<h4 class="mb-0">
|
|
|
|
|
<i class="bi bi-person-plus me-2"></i>
|
2025-06-08 11:13:43 +01:00
|
|
|
Add New Sender
|
2025-06-07 10:48:03 +01:00
|
|
|
</h4>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<form method="POST">
|
|
|
|
|
<div class="mb-3">
|
|
|
|
|
<label for="email" class="form-label">Email Address</label>
|
|
|
|
|
<input type="email"
|
|
|
|
|
class="form-control"
|
|
|
|
|
id="email"
|
|
|
|
|
name="email"
|
|
|
|
|
required
|
|
|
|
|
placeholder="user@example.com">
|
|
|
|
|
<div class="form-text">
|
|
|
|
|
The email address for authentication and sending
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="mb-3">
|
|
|
|
|
<label for="password" class="form-label">Password</label>
|
|
|
|
|
<input type="password"
|
|
|
|
|
class="form-control"
|
|
|
|
|
id="password"
|
|
|
|
|
name="password"
|
|
|
|
|
required
|
|
|
|
|
minlength="6">
|
|
|
|
|
<div class="form-text">
|
|
|
|
|
Minimum 6 characters
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="mb-3">
|
|
|
|
|
<label for="domain_id" class="form-label">Domain</label>
|
|
|
|
|
<select class="form-select" id="domain_id" name="domain_id" required>
|
|
|
|
|
<option value="">Select a domain...</option>
|
|
|
|
|
{% for domain in domains %}
|
|
|
|
|
<option value="{{ domain.id }}">{{ domain.domain_name }}</option>
|
|
|
|
|
{% endfor %}
|
|
|
|
|
</select>
|
|
|
|
|
<div class="form-text">
|
2025-06-08 11:13:43 +01:00
|
|
|
The domain this sender belongs to
|
2025-06-07 10:48:03 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="mb-4">
|
|
|
|
|
<div class="form-check">
|
|
|
|
|
<input class="form-check-input"
|
|
|
|
|
type="checkbox"
|
|
|
|
|
id="can_send_as_domain"
|
|
|
|
|
name="can_send_as_domain">
|
|
|
|
|
<label class="form-check-label" for="can_send_as_domain">
|
2025-06-08 11:13:43 +01:00
|
|
|
<strong>Domain Sender</strong>
|
2025-06-07 10:48:03 +01:00
|
|
|
</label>
|
|
|
|
|
<div class="form-text">
|
2025-06-08 11:13:43 +01:00
|
|
|
If checked, sender can send emails as any address in their domain.
|
|
|
|
|
Otherwise, sender can only send as their own email address.
|
2025-06-07 10:48:03 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="alert alert-info">
|
|
|
|
|
<h6 class="alert-heading">
|
|
|
|
|
<i class="bi bi-info-circle me-2"></i>
|
|
|
|
|
Permission Levels
|
|
|
|
|
</h6>
|
|
|
|
|
<ul class="mb-0">
|
2025-06-08 11:13:43 +01:00
|
|
|
<li><strong>Regular Sender:</strong> Can only send emails from their own email address</li>
|
|
|
|
|
<li><strong>Domain Sender:</strong> Can send emails from any address in their domain (e.g., noreply@domain.com, support@domain.com)</li>
|
2025-06-07 10:48:03 +01:00
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="d-flex justify-content-between">
|
2025-06-08 22:51:07 +01:00
|
|
|
<a href="{{ url_for('email.senders_list') }}" class="btn btn-secondary">
|
2025-06-07 10:48:03 +01:00
|
|
|
<i class="bi bi-arrow-left me-2"></i>
|
2025-06-08 11:13:43 +01:00
|
|
|
Back to Senders
|
2025-06-07 10:48:03 +01:00
|
|
|
</a>
|
|
|
|
|
<button type="submit" class="btn btn-success">
|
|
|
|
|
<i class="bi bi-person-plus me-2"></i>
|
2025-06-08 11:13:43 +01:00
|
|
|
Add Sender
|
2025-06-07 10:48:03 +01:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
|
|
{% block extra_js %}
|
|
|
|
|
<script>
|
|
|
|
|
// Auto-fill domain based on email input
|
|
|
|
|
document.getElementById('email').addEventListener('input', function(e) {
|
|
|
|
|
const email = e.target.value;
|
|
|
|
|
const atIndex = email.indexOf('@');
|
|
|
|
|
|
|
|
|
|
if (atIndex > -1) {
|
|
|
|
|
const domain = email.substring(atIndex + 1).toLowerCase();
|
|
|
|
|
const domainSelect = document.getElementById('domain_id');
|
|
|
|
|
|
|
|
|
|
// Try to find matching domain in select options
|
|
|
|
|
for (let option of domainSelect.options) {
|
|
|
|
|
if (option.text.toLowerCase() === domain) {
|
|
|
|
|
domainSelect.value = option.value;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Show/hide domain admin explanation
|
|
|
|
|
document.getElementById('can_send_as_domain').addEventListener('change', function(e) {
|
|
|
|
|
const isChecked = e.target.checked;
|
|
|
|
|
const domainSelect = document.getElementById('domain_id');
|
|
|
|
|
const selectedDomain = domainSelect.options[domainSelect.selectedIndex]?.text || 'domain.com';
|
|
|
|
|
|
|
|
|
|
// Update help text dynamically
|
|
|
|
|
const helpText = e.target.closest('.form-check').querySelector('.form-text');
|
|
|
|
|
if (isChecked) {
|
|
|
|
|
helpText.innerHTML = `User can send as any address in ${selectedDomain} (e.g., noreply@${selectedDomain}, support@${selectedDomain})`;
|
|
|
|
|
} else {
|
|
|
|
|
helpText.innerHTML = 'User can only send as their own email address.';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Update help text when domain changes
|
|
|
|
|
document.getElementById('domain_id').addEventListener('change', function(e) {
|
|
|
|
|
const checkbox = document.getElementById('can_send_as_domain');
|
|
|
|
|
if (checkbox.checked) {
|
|
|
|
|
checkbox.dispatchEvent(new Event('change'));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
{% endblock %}
|