feat: Update Nodemailer transport to support optional host and apiKey parameters, enhance error handling, and improve example usage
This commit is contained in:
parent
26d11289ea
commit
79b8013b5e
4 changed files with 395 additions and 344 deletions
|
@ -11,13 +11,8 @@ async function nodemailerTransportExample() {
|
|||
console.log('Nodemailer SMTP WebSocket Transport Example\n');
|
||||
|
||||
// Create the WebSocket transport
|
||||
const transport = createTransport({
|
||||
host: '192.168.0.62',
|
||||
apiKey: 'cebc9a7f-4e0c-4fda-9dd0-85f48c02800c',
|
||||
port: 80,
|
||||
secure: false, // Set to true for wss://
|
||||
debug: true
|
||||
});
|
||||
const apiKey = process.env.MXRELAY_API_KEY || 'your-api-key-here';
|
||||
const transport = createTransport(apiKey, {debug: false });
|
||||
|
||||
// Create Nodemailer transporter
|
||||
const transporter = nodemailer.createTransport(transport);
|
||||
|
@ -37,8 +32,8 @@ async function nodemailerTransportExample() {
|
|||
console.log('Sending test email...');
|
||||
|
||||
const info = await transporter.sendMail({
|
||||
from: 'cudconnex@satitm.chula.ac.th',
|
||||
to: 'siwat.s@chula.ac.th',
|
||||
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: `
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue