add SMTP sender
This commit is contained in:
@@ -12,6 +12,19 @@
|
||||
<form action="<?php echo e(route('mailing.invia')); ?>" method="POST" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
|
||||
<?php if(isset($senderAccounts) && $senderAccounts->count() > 0): ?>
|
||||
<div class="form-group">
|
||||
<label for="mittente_id">Mittente</label>
|
||||
<select name="mittente_id" id="mittente_id" class="form-control">
|
||||
<option value="">Sistema predefinito</option>
|
||||
<?php $__currentLoopData = $senderAccounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sender): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<option value="<?php echo e($sender->id); ?>"><?php echo e($sender->email_name ?: $sender->email_address); ?> <<?php echo e($sender->email_address); ?>></option>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
</select>
|
||||
<small class="text-muted">Seleziona un mittente per l'invio. Usa "Sistema predefinito" per inviare con l'account email principale.</small>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($individui->count() > 0): ?>
|
||||
<div class="form-group" id="destinatari-form-group">
|
||||
<label>Destinatari selezionati</label>
|
||||
|
||||
@@ -12,6 +12,19 @@
|
||||
<form action="<?php echo e(route('mailing.invio.elabora')); ?>" method="POST" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
|
||||
<?php if(isset($senderAccounts) && $senderAccounts->count() > 0): ?>
|
||||
<div class="form-group">
|
||||
<label for="mittente_id">Mittente</label>
|
||||
<select name="mittente_id" id="mittente_id" class="form-control">
|
||||
<option value="">Sistema predefinito</option>
|
||||
<?php $__currentLoopData = $senderAccounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sender): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<option value="<?php echo e($sender->id); ?>"><?php echo e($sender->email_name ?: $sender->email_address); ?> <<?php echo e($sender->email_address); ?>></option>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
</select>
|
||||
<small class="text-muted">Seleziona un mittente per l'invio massivo.</small>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Liste Destinatari *</label>
|
||||
<select name="liste[]" id="liste" class="form-control" multiple required size="4">
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php if($paginator->hasPages()): ?>
|
||||
<ul class="pagination justify-content-center" role="navigation">
|
||||
|
||||
<?php if($paginator->onFirstPage()): ?>
|
||||
<li class="page-item disabled" aria-disabled="true" aria-label="<?php echo app('translator')->get('pagination.previous'); ?>">
|
||||
<span class="page-link" aria-hidden="true">‹</span>
|
||||
</li>
|
||||
<?php else: ?>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="<?php echo e($paginator->previousPageUrl()); ?>" rel="prev" aria-label="<?php echo app('translator')->get('pagination.previous'); ?>">‹</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php $__currentLoopData = $elements; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
|
||||
<?php if(is_string($element)): ?>
|
||||
<li class="page-item disabled" aria-disabled="true"><span class="page-link"><?php echo e($element); ?></span></li>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if(is_array($element)): ?>
|
||||
<?php $__currentLoopData = $element; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $page => $url): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<?php if($page == $paginator->currentPage()): ?>
|
||||
<li class="page-item active" aria-current="page"><span class="page-link"><?php echo e($page); ?></span></li>
|
||||
<?php elseif($page >= $paginator->currentPage() - 2 && $page <= $paginator->currentPage() + 2): ?>
|
||||
<li class="page-item"><a class="page-link" href="<?php echo e($url); ?>"><?php echo e($page); ?></a></li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
|
||||
|
||||
<?php if($paginator->hasMorePages()): ?>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="<?php echo e($paginator->nextPageUrl()); ?>" rel="next" aria-label="<?php echo app('translator')->get('pagination.next'); ?>">›</a>
|
||||
</li>
|
||||
<?php else: ?>
|
||||
<li class="page-item disabled" aria-disabled="true" aria-label="<?php echo app('translator')->get('pagination.next'); ?>">
|
||||
<span class="page-link" aria-hidden="true">›</span>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
<?php endif; ?><?php /**PATH /var/www/html/glastree/resources/views/vendor/pagination/simple-bootstrap-4.blade.php ENDPATH**/ ?>
|
||||
@@ -30,6 +30,9 @@
|
||||
<a href="#signature" class="list-group-item list-group-item-action" data-toggle="tab">
|
||||
<i class="nav-icon fas fa-signature"></i> Firma
|
||||
</a>
|
||||
<a href="#mittenti" class="list-group-item list-group-item-action" data-toggle="tab">
|
||||
<i class="nav-icon fas fa-user-plus"></i> Mittenti Aggiuntivi
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -278,6 +281,100 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane" id="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">
|
||||
<?php if(session('success')): ?>
|
||||
<div class="alert alert-success"><?php echo e(session('success')); ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if(session('error')): ?>
|
||||
<div class="alert alert-danger"><?php echo e(session('error')); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php 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>
|
||||
<?php $__currentLoopData = $senderAccounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sender): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<tr>
|
||||
<td><strong><?php echo e($sender->email_address); ?></strong></td>
|
||||
<td><?php echo e($sender->email_name ?: '-'); ?></td>
|
||||
<td><small><?php echo e($sender->smtp_host ?: '-'); ?>:<?php echo e($sender->smtp_port ?: '-'); ?></small></td>
|
||||
<td><small class="text-muted"><?php echo e($sender->reply_to ?: '-'); ?></small></td>
|
||||
<td><small class="text-muted"><?php echo e($sender->verify_email ?: '-'); ?></small></td>
|
||||
<td>
|
||||
<?php if($sender->is_active): ?>
|
||||
<span class="badge badge-success">Attivo</span>
|
||||
<?php else: ?>
|
||||
<span class="badge badge-secondary">Disattivo</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-xs btn-info" onclick="editSender(<?php echo e($sender->id); ?>)" title="Modifica">
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-xs btn-success" onclick="testSenderSmtp(<?php echo e($sender->id); ?>)" title="Test SMTP">
|
||||
<i class="fas fa-paper-plane"></i>
|
||||
</button>
|
||||
<form action="<?php echo e(route('impostazioni.sender.destroy', $sender->id)); ?>" method="POST" class="d-inline" onsubmit="return confirm('Eliminare il mittente <?php echo e($sender->email_address); ?>?')">
|
||||
<?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
|
||||
<button type="submit" class="btn btn-xs btn-danger" title="Elimina">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php 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>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php 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>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
@@ -299,8 +396,180 @@
|
||||
</div>
|
||||
<?php $__env->stopSection(); ?>
|
||||
|
||||
<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="<?php echo e(route('impostazioni.sender.store')); ?>">
|
||||
<?php echo csrf_field(); ?>
|
||||
<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>
|
||||
|
||||
<?php $__env->startSection('scripts'); ?>
|
||||
<script>
|
||||
let senderAccounts = <?php echo json_encode($senderAccounts, 15, 512) ?>;
|
||||
|
||||
function resetSenderForm() {
|
||||
document.getElementById('senderForm').action = '<?php echo e(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 = '<?php echo e(route('impostazioni.sender.update', '')); ?>/' + 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 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: '<?php echo e(route('impostazioni.sender.test', '')); ?>/' + id,
|
||||
method: 'POST',
|
||||
headers: { 'X-CSRF-TOKEN': '<?php echo e(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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function testConnection() {
|
||||
$.ajax({
|
||||
url: '<?php echo e(route('impostazioni.email.test')); ?>',
|
||||
|
||||
@@ -9,9 +9,22 @@
|
||||
<h3 class="card-title"><i class="fas fa-edit mr-2"></i>Nuova Email</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="POST" action="<?php echo e(route('email.send')); ?>" id="emailForm">
|
||||
<form method="POST" action="<?php echo e(route('email.send')); ?>" id="emailForm" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
|
||||
<?php if($senderAccounts->count() > 0): ?>
|
||||
<div class="form-group">
|
||||
<label for="mittente_id">Da (mittente)</label>
|
||||
<select name="mittente_id" id="mittente_id" class="form-control">
|
||||
<option value="0">Sistema — <?php echo e(optional(\App\Models\EmailSetting::getActive())->email_address ?? 'Configura email'); ?></option>
|
||||
<?php $__currentLoopData = $senderAccounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sender): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<option value="<?php echo e($sender->id); ?>"><?php echo e($sender->email_name ?: $sender->email_address); ?> <<?php echo e($sender->email_address); ?>></option>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
</select>
|
||||
<small class="text-muted">Seleziona un mittente alternativo per l'invio. Lascia "Sistema" per usare l'account predefinito.</small>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Destinatari *</label>
|
||||
<div class="mb-2">
|
||||
|
||||
Reference in New Issue
Block a user