const nodemailer = require('nodemailer');

const transporter = nodemailer.createTransport({
  host: 'sandbox.smtp.mailtrap.io',
  port: 2525,
  auth: {
    user: '2597bd31d265eb',
    pass: 'cd126234193c89',
  },
});

console.log("🔄 Tentative d'envoi d'email...");

transporter
  .sendMail({
    from: 'noreply@xpeditis.com',
    to: 'test@example.com',
    subject: 'Test Email depuis Portail Transporteur',
    text: 'Email de test pour vérifier la configuration',
  })
  .then(info => {
    console.log('✅ Email envoyé:', info.messageId);
    console.log('📧 Response:', info.response);
    process.exit(0);
  })
  .catch(err => {
    console.error('❌ Erreur:', err.message);
    console.error('Code:', err.code);
    console.error('Command:', err.command);
    console.error('Stack:', err.stack);
    process.exit(1);
  });
