@emailcheck/email-validator-js 2.14.1 → 3.0.1-beta.0

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/README.md CHANGED
@@ -50,6 +50,14 @@
50
50
 
51
51
  ✅ **NEW:** RFC 5321 compliant validation
52
52
 
53
+ ✅ **NEW:** **Enhanced SMTP verification** with TLS/SSL support
54
+
55
+ ✅ **NEW:** **Multi-port testing** (25, 587, 465) with automatic port optimization
56
+
57
+ ✅ **NEW:** **Custom SMTP sequences** and command control (EHLO/HELO, VRFY, STARTTLS)
58
+
59
+ ✅ **NEW:** **Smart caching** for port performance and SMTP results
60
+
53
61
  ✅ **NEW:** Enhanced name detection from email addresses with composite name support
54
62
 
55
63
  ✅ **NEW:** Domain typo detection and suggestions with caching
@@ -674,6 +682,107 @@ const result = await verifyEmailBatch({
674
682
  // result.summary.processingTime: 234
675
683
  ```
676
684
 
685
+ ### Enhanced SMTP Verification (NEW)
686
+ ```typescript
687
+ import { verifyMailboxSMTP } from '@emailcheck/email-validator-js';
688
+ import { getDefaultCache } from '@emailcheck/email-validator-js';
689
+
690
+ // Direct SMTP verification with enhanced features
691
+ const { result, port, cached, portCached } = await verifyMailboxSMTP({
692
+ local: 'user',
693
+ domain: 'example.com',
694
+ mxRecords: ['mx.example.com'],
695
+ options: {
696
+ ports: [25, 587, 465], // Test multiple ports with TLS support
697
+ timeout: 5000,
698
+ cache: getDefaultCache(), // Smart caching for performance
699
+ debug: false,
700
+ tls: {
701
+ rejectUnauthorized: false, // Lenient TLS for compatibility
702
+ minVersion: 'TLSv1.2',
703
+ },
704
+ hostname: 'your-domain.com', // Custom EHLO hostname
705
+ useVRFY: true, // Enable VRFY command as fallback
706
+ },
707
+ });
708
+
709
+ // result: boolean - SMTP verification result
710
+ // port: number - The successful port used
711
+ // cached: boolean - If result was cached
712
+ // portCached: boolean - If port was cached from previous successful attempts
713
+ console.log(`SMTP result: ${result} via port ${port} (cached: ${cached || portCached})`);
714
+ ```
715
+
716
+ ### Advanced SMTP Configuration
717
+ ```typescript
718
+ import { verifyMailboxSMTP, SMTPStep } from '@emailcheck/email-validator-js';
719
+
720
+ // Custom SMTP command sequence
721
+ const { result } = await verifyMailboxSMTP({
722
+ local: 'user',
723
+ domain: 'example.com',
724
+ mxRecords: ['mx.example.com'],
725
+ options: {
726
+ sequence: {
727
+ steps: [
728
+ SMTPStep.GREETING,
729
+ SMTPStep.EHLO, // Extended SMTP
730
+ SMTPStep.STARTTLS, // Upgrade to TLS
731
+ SMTPStep.MAIL_FROM,
732
+ SMTPStep.RCPT_TO,
733
+ SMTPStep.VRFY, // Additional verification
734
+ ],
735
+ from: '<noreply@yourdomain.com>', // Custom MAIL FROM
736
+ },
737
+ ports: [587, 465], // Try STARTTLS first, then implicit TLS
738
+ maxRetries: 2,
739
+ },
740
+ });
741
+
742
+ // Port-specific optimization
743
+ const testPorts = async (email: string, mxHosts: string[]) => {
744
+ const [local, domain] = email.split('@');
745
+
746
+ const { result, port, portCached } = await verifyMailboxSMTP({
747
+ local,
748
+ domain,
749
+ mxRecords: mxHosts,
750
+ options: {
751
+ cache: getDefaultCache(),
752
+ // Port order matters: tests in sequence, stops at first success
753
+ ports: [587, 465, 25], // STARTTLS -> SMTPS -> SMTP
754
+ },
755
+ });
756
+
757
+ console.log(`Optimal port for ${domain}: ${port} (cached: ${portCached})`);
758
+ return { result, port };
759
+ };
760
+ ```
761
+
762
+ ### Running Examples
763
+
764
+ **Development (Recommended):**
765
+ ```bash
766
+ # Run examples with ts-node for full type checking
767
+ npx ts-node examples/smtp-usage.ts
768
+ npx ts-node examples/smtp-test.ts
769
+ npx ts-node examples/smtp-enhanced.ts
770
+ npx ts-node examples/smtp-comprehensive-tests.ts
771
+ npx ts-node examples/custom-cache-memory.ts
772
+ npx ts-node examples/smtp-sequences.ts
773
+ ```
774
+
775
+ **Direct TypeScript Execution (v2.14.0+):**
776
+ ```bash
777
+ # After the next release (v2.14.0) with updated distribution exports:
778
+ yarn build
779
+ node --experimental-strip-types examples/smtp-usage.ts
780
+
781
+ # Requires Node.js 20.10+ or Node.js 21.0+ for --experimental-strip-types support
782
+ ```
783
+
784
+ **For current development, use `npx ts-node` which imports directly from source files with full type checking.**
785
+
677
786
  ### Name Detection (ENHANCED)
678
787
  ```typescript
679
788
  import { detectName, verifyEmail } from '@emailcheck/email-validator-js';
@@ -48,6 +48,7 @@ export interface ICache {
48
48
  free: ICacheStore<boolean>;
49
49
  domainValid: ICacheStore<boolean>;
50
50
  smtp: ICacheStore<boolean | null>;
51
+ smtpPort: ICacheStore<number>;
51
52
  domainSuggestion: ICacheStore<{
52
53
  suggested: string;
53
54
  confidence: number;
package/dist/cache.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare const DEFAULT_CACHE_OPTIONS: {
9
9
  free: number;
10
10
  domainValid: number;
11
11
  smtp: number;
12
+ smtpPort: number;
12
13
  domainSuggestion: number;
13
14
  whois: number;
14
15
  };
@@ -18,6 +19,7 @@ export declare const DEFAULT_CACHE_OPTIONS: {
18
19
  free: number;
19
20
  domainValid: number;
20
21
  smtp: number;
22
+ smtpPort: number;
21
23
  domainSuggestion: number;
22
24
  whois: number;
23
25
  };