Fix MakerWorld 2FA duplicate email loop and add email SMTP diagnostics
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Throwable;
|
||||
|
||||
class TestMailCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:test-mail {email : Het e-mailadres van de ontvanger (bijv. je eigen Gmail)}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Verstuur een test e-mail en controleer de mailer/SMTP verbinding';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$recipient = $this->argument('email');
|
||||
$defaultMailer = config('mail.default');
|
||||
$smtpConfig = config("mail.mailers.{$defaultMailer}", []);
|
||||
$fromAddress = config('mail.from.address');
|
||||
$fromName = config('mail.from.name');
|
||||
|
||||
$this->info('=== Jouwdriedee.nl E-mail & SMTP Diagnostiek ===');
|
||||
$this->table(['Instelling', 'Waarde'], [
|
||||
['Actieve Mailer (MAIL_MAILER)', $defaultMailer],
|
||||
['Verzender Adres (MAIL_FROM_ADDRESS)', $fromAddress],
|
||||
['Verzender Naam (MAIL_FROM_NAME)', $fromName],
|
||||
['SMTP Host', $smtpConfig['host'] ?? 'N.v.t. (geen smtp)'],
|
||||
['SMTP Poort', $smtpConfig['port'] ?? 'N.v.t.'],
|
||||
['SMTP Gebruiker', ! empty($smtpConfig['username']) ? $smtpConfig['username'] : '(geen / leeg)'],
|
||||
['SMTP Wachtwoord ingesteld?', ! empty($smtpConfig['password']) ? 'Ja' : 'Nee'],
|
||||
['Ontvanger', $recipient],
|
||||
]);
|
||||
|
||||
if ($defaultMailer === 'log') {
|
||||
$this->warn("⚠️ WAARSCHUWING: MAIL_MAILER staat momenteel op 'log'!");
|
||||
$this->warn('Dit betekent dat er GEEN echte mail via internet wordt verzonden naar Gmail.');
|
||||
$this->warn('De mail wordt weggeschreven naar storage/logs/laravel.log.');
|
||||
$this->warn('Stel MAIL_MAILER=smtp in met geldige SMTP-gegevens op Coolify om echte mails te ontvangen.');
|
||||
}
|
||||
|
||||
$this->line("\nVersturen van testmail naar {$recipient}...");
|
||||
|
||||
try {
|
||||
Mail::raw("Dit is een test e-mail vanaf Jouwdriedee.nl om te controleren of de mailserver en bezorging naar {$recipient} correct functioneert.\n\nVerzonden op: ".now()->toIso8601String(), function ($message) use ($recipient) {
|
||||
$message->to($recipient)
|
||||
->subject('Test E-mail vanaf Jouwdriedee.nl');
|
||||
});
|
||||
|
||||
$this->info("✓ Test e-mail succesvol verzonden via driver '{$defaultMailer}'!");
|
||||
if ($defaultMailer === 'log') {
|
||||
$this->comment('Controleer storage/logs/laravel.log om de gelogde e-mail te zien.');
|
||||
} else {
|
||||
$this->info("Controleer nu je inbox (en eventueel spambox) op {$recipient}.");
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
} catch (Throwable $e) {
|
||||
$this->error('❌ FOUT BIJ HET VERZENDEN:');
|
||||
$this->error($e->getMessage());
|
||||
$this->line("\nStack trace:");
|
||||
$this->line($e->getTraceAsString());
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user