Mailversand: Brevo durch All-Inkl-SMTP ersetzt + sendefreier Verbindungstest
Versand läuft jetzt über das KAS-Postfach noreply@tsv08kulmbach.de (w01ca75d.kasserver.com:587, STARTTLS) — ein Drittanbieter weniger, SPF der Domain deckt den Server bereits ab. bin/smtp-test.php prüft Verbindung, TLS und Login ohne eine Mail zu versenden (Debug bewusst aus, damit keine Credentials im Terminal landen). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
52
bin/smtp-test.php
Normal file
52
bin/smtp-test.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SMTP-Verbindungstest — prüft Host, STARTTLS und Login aus config/config.php,
|
||||
* OHNE eine E-Mail zu versenden (nur Verbindung + Auth, danach QUIT).
|
||||
*
|
||||
* NUR CLI — nie im Request-Pfad. Debug-Ausgabe bleibt aus, damit keine
|
||||
* Zugangsdaten (Base64 im AUTH-Dialog) im Terminal oder in Logs landen.
|
||||
*
|
||||
* Aufruf: php bin/smtp-test.php
|
||||
*/
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require dirname(__DIR__) . '/app/bootstrap.php';
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
$smtp = config('smtp');
|
||||
|
||||
if (in_array($smtp['password'] ?? '', ['', 'POSTFACH_PASSWORT', 'BREVO_SMTP_KEY', 'CHANGE_ME'], true)) {
|
||||
fwrite(STDERR, "Abbruch: In config/config.php steht noch kein echtes SMTP-Passwort.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "Teste {$smtp['host']}:{$smtp['port']} (STARTTLS) als {$smtp['username']} …\n";
|
||||
|
||||
$mail = new PHPMailer(true);
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $smtp['host'];
|
||||
$mail->Port = (int) $smtp['port'];
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$mail->Username = $smtp['username'];
|
||||
$mail->Password = $smtp['password'];
|
||||
$mail->Timeout = 15;
|
||||
|
||||
try {
|
||||
if ($mail->smtpConnect()) {
|
||||
$mail->smtpClose();
|
||||
echo "OK: Verbindung, STARTTLS und Login erfolgreich — keine Mail versendet.\n";
|
||||
exit(0);
|
||||
}
|
||||
fwrite(STDERR, 'Fehler: ' . ($mail->ErrorInfo !== '' ? $mail->ErrorInfo : 'Verbindung fehlgeschlagen.') . "\n");
|
||||
exit(1);
|
||||
} catch (Throwable $e) {
|
||||
fwrite(STDERR, 'Fehler: ' . $e->getMessage() . "\n");
|
||||
exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user