fine implementazione multi-sentder
This commit is contained in:
@@ -190,6 +190,7 @@
|
||||
<li class="nav-item"><a href="#email-account" class="nav-link" data-toggle="tab">Account</a></li>
|
||||
<li class="nav-item"><a href="#email-sync" class="nav-link" data-toggle="tab">Sincronizzazione</a></li>
|
||||
<li class="nav-item"><a href="#email-firma" class="nav-link" data-toggle="tab">Firma</a></li>
|
||||
<li class="nav-item"><a href="#email-mittenti" class="nav-link" data-toggle="tab">Mittenti Aggiuntivi</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -427,6 +428,97 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane" id="email-mittenti">
|
||||
<div class="card card-primary">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Mittenti Aggiuntivi</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-sm btn-success" data-toggle="modal" data-target="#senderModal" onclick="resetSenderForm()">
|
||||
<i class="fas fa-plus mr-1"></i> Nuovo Mittente
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@if(session('success'))
|
||||
<div class="alert alert-success">{{ session('success') }}</div>
|
||||
@endif
|
||||
@if(session('error'))
|
||||
<div class="alert alert-danger">{{ session('error') }}</div>
|
||||
@endif
|
||||
|
||||
@if($senderAccounts->count() > 0)
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Email</th>
|
||||
<th>Nome</th>
|
||||
<th>SMTP</th>
|
||||
<th>Reply-To</th>
|
||||
<th>Verify</th>
|
||||
<th>Stato</th>
|
||||
<th style="width: 160px;">Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($senderAccounts as $sender)
|
||||
<tr>
|
||||
<td><strong>{{ $sender->email_address }}</strong></td>
|
||||
<td>{{ $sender->email_name ?: '-' }}</td>
|
||||
<td><small>{{ $sender->smtp_host ?: '-' }}:{{ $sender->smtp_port ?: '-' }}</small></td>
|
||||
<td><small class="text-muted">{{ $sender->reply_to ?: '-' }}</small></td>
|
||||
<td><small class="text-muted">{{ $sender->verify_email ?: '-' }}</small></td>
|
||||
<td>
|
||||
@if($sender->is_active)
|
||||
<span class="badge badge-success">Attivo</span>
|
||||
@else
|
||||
<span class="badge badge-secondary">Disattivo</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-xs btn-info" onclick="editSender({{ $sender->id }})" title="Modifica">
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-xs btn-success" onclick="testSenderSmtp({{ $sender->id }})" title="Test SMTP">
|
||||
<i class="fas fa-paper-plane"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-xs btn-danger" onclick="deleteSender({{ $sender->id }}, '{{ addslashes($sender->email_address) }}')" title="Elimina">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@else
|
||||
<div class="text-center text-muted py-4">
|
||||
<i class="fas fa-user-plus fa-2x mb-2"></i>
|
||||
<p class="mb-0">Nessun mittente aggiuntivo configurato.</p>
|
||||
<p class="mb-0">Usa il pulsante "Nuovo Mittente" per aggiungere un account di invio dedicato (es. Newsletter).</p>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if($senderAccounts->count() > 0)
|
||||
<div class="card card-secondary">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><i class="fas fa-info-circle mr-2"></i>Come funziona</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="mb-0">
|
||||
<li>I mittenti aggiuntivi sono account <strong>solo invio</strong> (SMTP) senza IMAP.</li>
|
||||
<li>Puoi selezionarli nel <strong>compose email</strong> o negli <strong>invii mailing</strong>.</li>
|
||||
<li>Il campo <strong>Reply-To</strong> imposta l'indirizzo di risposta (es. <code>no-reply@parrocchia.it</code>).</li>
|
||||
<li>Il campo <strong>Verify Email</strong> riceve un report di riepilogo dopo ogni invio massivo con l'esito (ok/falliti).</li>
|
||||
<li>Se Reply-To non è impostato, viene usato Verify Email come fallback.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
@@ -890,6 +982,113 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- ===== MODALE MITTENTI AGGIUNTIVI ===== --}}
|
||||
<div class="modal fade" id="senderModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<form id="senderForm" method="POST" action="{{ route('impostazioni.sender.store') }}">
|
||||
@csrf
|
||||
<input type="hidden" name="_method" id="senderMethod" value="POST">
|
||||
<input type="hidden" name="id" id="senderId" value="">
|
||||
<div class="modal-header bg-primary">
|
||||
<h5 class="modal-title" id="senderModalTitle"><i class="fas fa-user-plus mr-2"></i>Nuovo Mittente</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="sender_email">Email *</label>
|
||||
<input type="email" name="email_address" id="sender_email" class="form-control" required placeholder="newsletter@parrocchia.it">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="sender_name">Nome visualizzato</label>
|
||||
<input type="text" name="email_name" id="sender_name" class="form-control" placeholder="Newsletter Parrocchiale">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<h6>Configurazione SMTP</h6>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="sender_smtp_host">Host SMTP</label>
|
||||
<input type="text" name="smtp_host" id="sender_smtp_host" class="form-control" placeholder="smtp.gmail.com">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="sender_smtp_port">Porta</label>
|
||||
<input type="number" name="smtp_port" id="sender_smtp_port" class="form-control" value="587">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="sender_smtp_encryption">Crittografia</label>
|
||||
<select name="smtp_encryption" id="sender_smtp_encryption" class="form-control">
|
||||
<option value="tls">TLS</option>
|
||||
<option value="ssl">SSL</option>
|
||||
<option value="none">Nessuna</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="sender_smtp_username">Username SMTP</label>
|
||||
<input type="text" name="smtp_username" id="sender_smtp_username" class="form-control" placeholder="Lascia vuoto per usare l'email">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="sender_smtp_password">Password SMTP</label>
|
||||
<input type="password" name="smtp_password" id="sender_smtp_password" class="form-control" placeholder="......">
|
||||
<small class="text-muted">Lascia vuoto per non cambiare</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="sender_reply_to">Reply-To <small class="text-muted">(no-reply)</small></label>
|
||||
<input type="email" name="reply_to" id="sender_reply_to" class="form-control" placeholder="no-reply@parrocchia.it">
|
||||
<small class="text-muted">Indirizzo di risposta per le email inviate</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="sender_verify_email">Verify Email <small class="text-muted">(report)</small></label>
|
||||
<input type="email" name="verify_email" id="sender_verify_email" class="form-control" placeholder="verifica@parrocchia.it">
|
||||
<small class="text-muted">Riceve report riepilogo dopo invii massivi</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="sender_note">Nota interna</label>
|
||||
<textarea name="note" id="sender_note" class="form-control" rows="2" placeholder="Es. Newsletter settimanale"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="sender_is_active" name="is_active" value="1" checked>
|
||||
<label class="custom-control-label" for="sender_is_active">Mittente attivo</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annulla</button>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-save mr-1"></i> Salva Mittente
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
@@ -1007,6 +1206,92 @@ $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||
}
|
||||
});
|
||||
|
||||
// ===== MITTENTI AGGIUNTIVI =====
|
||||
let senderAccounts = @json($senderAccounts);
|
||||
|
||||
function resetSenderForm() {
|
||||
document.getElementById('senderForm').action = '{{ route('impostazioni.sender.store') }}';
|
||||
document.getElementById('senderMethod').value = 'POST';
|
||||
document.getElementById('senderModalTitle').textContent = 'Nuovo Mittente';
|
||||
document.getElementById('senderForm').reset();
|
||||
document.getElementById('senderId').value = '';
|
||||
document.getElementById('sender_is_active').checked = true;
|
||||
document.getElementById('sender_smtp_password').placeholder = '';
|
||||
document.getElementById('sender_smtp_password').required = false;
|
||||
}
|
||||
|
||||
function editSender(id) {
|
||||
const sender = senderAccounts.find(s => s.id === id);
|
||||
if (!sender) return;
|
||||
|
||||
document.getElementById('senderForm').action = '{{ route('impostazioni.sender.update', '__ID__') }}'.replace('__ID__', id);
|
||||
document.getElementById('senderMethod').value = 'PUT';
|
||||
document.getElementById('senderModalTitle').textContent = 'Modifica Mittente - ' + sender.email_address;
|
||||
document.getElementById('senderId').value = sender.id;
|
||||
document.getElementById('sender_email').value = sender.email_address;
|
||||
document.getElementById('sender_name').value = sender.email_name || '';
|
||||
document.getElementById('sender_smtp_host').value = sender.smtp_host || '';
|
||||
document.getElementById('sender_smtp_port').value = sender.smtp_port || 587;
|
||||
document.getElementById('sender_smtp_encryption').value = sender.smtp_encryption || 'tls';
|
||||
document.getElementById('sender_smtp_username').value = sender.smtp_username || '';
|
||||
document.getElementById('sender_smtp_password').value = '';
|
||||
document.getElementById('sender_smtp_password').placeholder = '......';
|
||||
document.getElementById('sender_smtp_password').required = false;
|
||||
document.getElementById('sender_reply_to').value = sender.reply_to || '';
|
||||
document.getElementById('sender_verify_email').value = sender.verify_email || '';
|
||||
document.getElementById('sender_note').value = sender.note || '';
|
||||
document.getElementById('sender_is_active').checked = sender.is_active;
|
||||
|
||||
$('#senderModal').modal('show');
|
||||
}
|
||||
|
||||
function deleteSender(id, email) {
|
||||
if (!confirm('Eliminare il mittente ' + email + '?')) return;
|
||||
var url = '{{ route('impostazioni.sender.destroy', '__ID__') }}'.replace('__ID__', id);
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}',
|
||||
'X-HTTP-Method-Override': 'DELETE'
|
||||
}
|
||||
}).then(function(r) { return r.json(); }).then(function(data) {
|
||||
if (data.success) {
|
||||
location.reload();
|
||||
} else {
|
||||
alert('❌ ' + (data.message || 'Errore'));
|
||||
}
|
||||
}).catch(function() {
|
||||
alert('❌ Errore di rete');
|
||||
});
|
||||
}
|
||||
|
||||
function testSenderSmtp(id) {
|
||||
const email = prompt('Inserisci l\'indirizzo email a cui inviare il test:');
|
||||
if (!email || !email.includes('@')) return;
|
||||
|
||||
const btn = event.target;
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i>';
|
||||
|
||||
$.ajax({
|
||||
url: '{{ route('impostazioni.sender.test', '__ID__') }}'.replace('__ID__', id),
|
||||
method: 'POST',
|
||||
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||
data: { email: email },
|
||||
timeout: 30000,
|
||||
success: function(response) {
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<i class="fas fa-paper-plane"></i>';
|
||||
alert(response.success ? '✅ ' + response.message : '❌ ' + response.message);
|
||||
},
|
||||
error: function(xhr) {
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<i class="fas fa-paper-plane"></i>';
|
||||
const msg = xhr.responseJSON?.message || 'Errore di connessione';
|
||||
alert('❌ ' + msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
// ===== EMAIL FUNCTIONS =====
|
||||
function testConnection() {
|
||||
$.ajax({
|
||||
|
||||
Reference in New Issue
Block a user