#!/usr/bin/env ts-node /** * Nodemailer transport example for SMTP over WebSocket */ import nodemailer from 'nodemailer'; import { createTransport } from '../src/index'; async function nodemailerTransportExample() { console.log('Nodemailer SMTP WebSocket Transport Example\n'); // Create the WebSocket transport const transport = createTransport({ host: '192.168.0.62', port: 80, secure: false, // Set to true for wss:// auth: { user: 'cebc9a7f-4e0c-4fda-9dd0-85f48c02800c' // Your SMTP relay API key }, debug: true }); // Create Nodemailer transporter const transporter = nodemailer.createTransport(transport); // Verify the transport configuration try { console.log('Verifying transport configuration...'); await transporter.verify(); console.log('Transport verification successful\n'); } catch (error) { console.error('Transport verification failed:', error); return; } // Send a test email try { console.log('Sending test email...'); const info = await transporter.sendMail({ from: 'sender@example.com', to: 'recipient@example.com', subject: 'Test Email via SMTP WebSocket', text: 'This email was sent using the SMTP WebSocket transport!', html: `
This email was sent using the SMTP WebSocket transport!
Features: