nolimit-x 1.0.78 → 1.0.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/processor.js +13 -4
- package/src/sender.js +72 -15
package/package.json
CHANGED
package/src/processor.js
CHANGED
|
@@ -43,13 +43,22 @@ class ConfigManager {
|
|
|
43
43
|
const smtpRotation = this.config.configurations?.system?.smtp_rotation || false;
|
|
44
44
|
|
|
45
45
|
if (smtpRotation) {
|
|
46
|
-
// Load multiple SMTP providers from
|
|
47
|
-
|
|
46
|
+
// Load multiple SMTP providers from smtps.txt
|
|
47
|
+
const externalProviders = this.loadSmtpProviders();
|
|
48
|
+
// Merge config.json SMTP(s) + smtps.txt into one pool, deduplicated by host+user
|
|
49
|
+
const configSmtps = Array.isArray(this.config.smtp) ? this.config.smtp : [this.config.smtp];
|
|
50
|
+
const combined = [...configSmtps, ...externalProviders];
|
|
51
|
+
const seen = new Set();
|
|
52
|
+
this.smtpConfigs = combined.filter(s => {
|
|
53
|
+
const key = `${s.host}:${s.port}:${s.user}`;
|
|
54
|
+
if (seen.has(key)) return false;
|
|
55
|
+
seen.add(key);
|
|
56
|
+
return true;
|
|
57
|
+
});
|
|
48
58
|
if (this.smtpConfigs.length === 0) {
|
|
49
|
-
console.warn('SMTP rotation enabled but no providers found in smtps.txt, falling back to config.json');
|
|
50
59
|
this.smtpConfig = this.config.smtp[0];
|
|
51
60
|
} else {
|
|
52
|
-
this.smtpConfig = this.smtpConfigs[0];
|
|
61
|
+
this.smtpConfig = this.smtpConfigs[0];
|
|
53
62
|
}
|
|
54
63
|
} else {
|
|
55
64
|
// Use single SMTP from config.json
|
package/src/sender.js
CHANGED
|
@@ -498,26 +498,83 @@ async function send(options) {
|
|
|
498
498
|
|
|
499
499
|
if (allJobs.length > 0) {
|
|
500
500
|
console.log('');
|
|
501
|
-
const results = await sendEmailViaRust(allJobs, useRawSmtp);
|
|
502
501
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
502
|
+
// Health-aware SMTP rotation: send → detect dead SMTPs → retry failed through healthy ones
|
|
503
|
+
const deadSmtps = new Set(); // permanently failed (535 auth)
|
|
504
|
+
const ratelimited = new Set(); // temporarily exhausted (554 rate limit)
|
|
505
|
+
let pendingJobs = allJobs;
|
|
506
|
+
let pendingEmails = allEmails;
|
|
507
|
+
let retryRound = 0;
|
|
508
|
+
const MAX_RETRIES = 2;
|
|
509
|
+
|
|
510
|
+
while (pendingJobs.length > 0) {
|
|
511
|
+
const results = await sendEmailViaRust(pendingJobs, useRawSmtp);
|
|
512
|
+
const retryJobs = [];
|
|
513
|
+
const retryEmails = [];
|
|
514
|
+
|
|
515
|
+
for (let i = 0; i < results.length; i++) {
|
|
516
|
+
const result = results[i];
|
|
517
|
+
const email = pendingEmails[i];
|
|
518
|
+
const job = pendingJobs[i];
|
|
519
|
+
const sender = job.from || job.from_email;
|
|
520
|
+
const smtpUser = job.smtp?.[0]?.user || '';
|
|
521
|
+
|
|
522
|
+
if (configManager.config.configurations.multiple_senders === true && sender) {
|
|
523
|
+
senderRanker.updateSenderSuccess(sender, result.success);
|
|
524
|
+
}
|
|
507
525
|
|
|
508
|
-
|
|
509
|
-
|
|
526
|
+
if (result.success) {
|
|
527
|
+
campaign.successfulSends++;
|
|
528
|
+
totalSent++;
|
|
529
|
+
try { senderIntel.recordSuccessfulSend(campaignId, sender, email, result); } catch (e) { }
|
|
530
|
+
} else {
|
|
531
|
+
const errMsg = (result.error || result.message || '').toLowerCase();
|
|
532
|
+
if (errMsg.includes('535') || errMsg.includes('authentication failed')) {
|
|
533
|
+
deadSmtps.add(smtpUser);
|
|
534
|
+
retryJobs.push(job);
|
|
535
|
+
retryEmails.push(email);
|
|
536
|
+
} else if (errMsg.includes('554') || errMsg.includes('limit')) {
|
|
537
|
+
ratelimited.add(smtpUser);
|
|
538
|
+
retryJobs.push(job);
|
|
539
|
+
retryEmails.push(email);
|
|
540
|
+
} else {
|
|
541
|
+
// Genuine send failure — don't retry
|
|
542
|
+
campaign.failedSends++;
|
|
543
|
+
try { senderIntel.recordFailedSend(campaignId, sender, email, result); } catch (e) { }
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
campaign.processedEmails++;
|
|
510
547
|
}
|
|
511
548
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
549
|
+
retryRound++;
|
|
550
|
+
if (retryRound > MAX_RETRIES || retryJobs.length === 0) {
|
|
551
|
+
// Mark remaining retries as failed
|
|
552
|
+
if (retryJobs.length > 0) {
|
|
553
|
+
campaign.failedSends += retryJobs.length;
|
|
554
|
+
}
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// Healthy SMTPs = pool minus dead and ratelimited
|
|
559
|
+
const healthySmtps = _smtpRotation
|
|
560
|
+
? _smtpArr.filter(s => !deadSmtps.has(s.user) && !ratelimited.has(s.user))
|
|
561
|
+
: [];
|
|
562
|
+
|
|
563
|
+
if (healthySmtps.length === 0) {
|
|
564
|
+
// No healthy SMTPs left — mark all as failed
|
|
565
|
+
campaign.failedSends += retryJobs.length;
|
|
566
|
+
break;
|
|
519
567
|
}
|
|
520
|
-
|
|
568
|
+
|
|
569
|
+
// Reassign failed jobs to healthy SMTPs
|
|
570
|
+
for (let i = 0; i < retryJobs.length; i++) {
|
|
571
|
+
const smtp = healthySmtps[i % healthySmtps.length];
|
|
572
|
+
retryJobs[i].smtp = [smtp];
|
|
573
|
+
retryJobs[i].from = smtp.user;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
pendingJobs = retryJobs;
|
|
577
|
+
pendingEmails = retryEmails;
|
|
521
578
|
}
|
|
522
579
|
}
|
|
523
580
|
// End campaign
|