xpeditis2.0/apps/backend/test-email-ip.js
2025-12-05 13:55:40 +01:00

66 lines
1.9 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Test email with IP address directly (bypass DNS)
*/
const nodemailer = require('nodemailer');
const config = {
host: '3.209.246.195', // IP directe de smtp.mailtrap.io
port: 2525,
secure: false,
auth: {
user: '2597bd31d265eb',
pass: 'cd126234193c89',
},
connectionTimeout: 10000,
greetingTimeout: 10000,
socketTimeout: 30000,
tls: {
rejectUnauthorized: false,
servername: 'smtp.mailtrap.io', // Important pour TLS
},
};
console.log('🧪 Testing SMTP with IP address directly...');
console.log('Config:', {
...config,
auth: { user: config.auth.user, pass: '***' },
});
const transporter = nodemailer.createTransport(config);
console.log('\n1⃣ Verifying SMTP connection...');
transporter.verify()
.then(() => {
console.log('✅ SMTP connection verified!');
console.log('\n2⃣ Sending test email...');
return transporter.sendMail({
from: 'noreply@xpeditis.com',
to: 'test@example.com',
subject: 'Test Xpeditis - Envoi Direct IP',
html: '<h1>✅ Email envoyé avec succès!</h1><p>Ce test utilise l\'IP directe pour contourner le DNS.</p>',
});
})
.then((info) => {
console.log('✅ Email sent successfully!');
console.log('📧 Message ID:', info.messageId);
console.log('📬 Response:', info.response);
console.log('\n🎉 SUCCESS! Email sending works with IP directly.');
process.exit(0);
})
.catch((error) => {
console.error('\n❌ ERROR:', error.message);
console.error('Code:', error.code);
console.error('Command:', error.command);
if (error.code === 'EAUTH') {
console.error('\n⚠ Authentication failed - credentials may be invalid');
} else if (error.code === 'ETIMEDOUT' || error.code === 'ECONNREFUSED') {
console.error('\n⚠ Connection failed - firewall or network issue');
}
process.exit(1);
});