fix mail 2
This commit is contained in:
130
test_email.php
Normal file
130
test_email.php
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Test Invio Email
|
||||||
|
*
|
||||||
|
* Utility per testare la configurazione SMTP
|
||||||
|
* ELIMINA QUESTO FILE dopo aver verificato che le email funzionino!
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once 'includes/config.php';
|
||||||
|
require_once 'includes/functions.php';
|
||||||
|
|
||||||
|
$message = '';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$test_email = $_POST['email'] ?? '';
|
||||||
|
|
||||||
|
if (!empty($test_email) && filter_var($test_email, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$subject = "Test Email - " . SITE_NAME;
|
||||||
|
|
||||||
|
$body = "
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
body { font-family: Arial, sans-serif; }
|
||||||
|
.container { max-width: 600px; margin: 0 auto; padding: 20px; }
|
||||||
|
.success { color: #2ECC71; font-weight: bold; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class='container'>
|
||||||
|
<h2>Test Email Configurazione SMTP</h2>
|
||||||
|
<p class='success'>✅ Congratulazioni! La configurazione SMTP funziona correttamente.</p>
|
||||||
|
<p>Hai ricevuto questa email di test da <strong>" . SITE_NAME . "</strong></p>
|
||||||
|
<p>Ora puoi eliminare il file <code>test_email.php</code> dalla root del progetto.</p>
|
||||||
|
<hr>
|
||||||
|
<p style='color: #666; font-size: 12px;'>
|
||||||
|
Configurazione SMTP:<br>
|
||||||
|
Host: " . SMTP_HOST . "<br>
|
||||||
|
Port: " . SMTP_PORT . "<br>
|
||||||
|
Username: " . SMTP_USERNAME . "
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
";
|
||||||
|
|
||||||
|
if (send_email($test_email, $subject, $body)) {
|
||||||
|
$message = '<div class="alert alert-success">✅ Email inviata con successo a ' . htmlspecialchars($test_email) . '! Controlla la tua casella (anche spam).</div>';
|
||||||
|
} else {
|
||||||
|
$message = '<div class="alert alert-error">❌ Errore durante l\'invio. Verifica le credenziali SMTP in config.php e controlla i log PHP.</div>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$message = '<div class="alert alert-error">Inserisci un indirizzo email valido</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="it">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Test Email SMTP</title>
|
||||||
|
<link rel="stylesheet" href="assets/css/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container" style="margin-top: 3rem;">
|
||||||
|
<div class="container-sm">
|
||||||
|
<div class="card">
|
||||||
|
<h1 style="text-align: center; color: var(--primary-color); margin-bottom: 1rem;">
|
||||||
|
📧 Test Email SMTP
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<p style="text-align: center; margin-bottom: 2rem; color: var(--gray-600);">
|
||||||
|
Verifica la configurazione Gmail SMTP
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?php echo $message; ?>
|
||||||
|
|
||||||
|
<div style="background: var(--secondary-color); padding: 1rem; border-radius: var(--radius-md); margin-bottom: 1.5rem;">
|
||||||
|
<h3 style="margin-bottom: 0.5rem;">Configurazione Attuale:</h3>
|
||||||
|
<ul style="margin: 0; padding-left: 1.5rem;">
|
||||||
|
<li><strong>SMTP Attivo:</strong> <?php echo USE_SMTP ? '✅ Sì' : '❌ No (usa mail() PHP)'; ?></li>
|
||||||
|
<li><strong>Host:</strong> <?php echo defined('SMTP_HOST') ? SMTP_HOST : 'Non configurato'; ?></li>
|
||||||
|
<li><strong>Porta:</strong> <?php echo defined('SMTP_PORT') ? SMTP_PORT : 'Non configurato'; ?></li>
|
||||||
|
<li><strong>Username:</strong> <?php echo defined('SMTP_USERNAME') ? SMTP_USERNAME : 'Non configurato'; ?></li>
|
||||||
|
<li><strong>Password:</strong> <?php echo defined('SMTP_PASSWORD') && SMTP_PASSWORD !== 'tua-password-applicazione' ? '✅ Configurata' : '❌ Non configurata'; ?></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if (!USE_SMTP || !defined('SMTP_PASSWORD') || SMTP_PASSWORD === 'tua-password-applicazione'): ?>
|
||||||
|
<div class="alert alert-error">
|
||||||
|
<strong>⚠️ Configurazione Incompleta!</strong><br>
|
||||||
|
Apri <code>includes/config.php</code> e configura:
|
||||||
|
<ul style="margin-top: 0.5rem;">
|
||||||
|
<li>Imposta <code>USE_SMTP</code> a <code>true</code></li>
|
||||||
|
<li>Inserisci la tua email Gmail in <code>SMTP_USERNAME</code></li>
|
||||||
|
<li>Genera e inserisci la Password Applicazione Gmail in <code>SMTP_PASSWORD</code></li>
|
||||||
|
</ul>
|
||||||
|
<p style="margin-top: 1rem;">
|
||||||
|
<a href="https://myaccount.google.com/apppasswords" target="_blank" class="btn btn-primary btn-small">
|
||||||
|
Genera Password App Gmail →
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<form method="POST" action="">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="email" class="form-label">Email destinatario (tua email per test)</label>
|
||||||
|
<input type="email" id="email" name="email" class="form-control"
|
||||||
|
required placeholder="tua-email@esempio.com">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary" style="width: 100%;">
|
||||||
|
📤 Invia Email di Test
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div style="margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--gray-300); text-align: center; color: var(--gray-600); font-size: 0.875rem;">
|
||||||
|
<strong>⚠️ IMPORTANTE:</strong> Elimina questo file (<code>test_email.php</code>) dopo il test!
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="margin-top: 1rem; text-align: center;">
|
||||||
|
<a href="index.php" class="btn btn-outline">← Torna alla Home</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user