--- id: AIDotNet/MoYuCode/nodemailer version: "9c02ddbc" license: MIT install: manual updated: 2026-01-28 --- # nodemailer — nodemailer enables Node.js developers to dispatch transactional emails programmatically with straightforward configuration and robust delivery handling. Whether you're sending password resets, order confirmations, or notifications, this skill integrates email functionality directly into your application workflow. Publisher: AIDotNet · Stars: 84 · Updated: 2026-01-28 Install (manual): `git clone https://github.com/AIDotNet/MoYuCode` ## SKILL.md # Nodemailer Tool ## Description Send emails from Node.js with SMTP, OAuth2, attachments, and HTML templates. ## Source - Repository: [nodemailer/nodemailer](https://github.com/nodemailer/nodemailer) - License: MIT ## Installation ```bash npm install nodemailer ``` ## Usage Examples ### Basic Email ```typescript import nodemailer from 'nodemailer'; const transporter = nodemailer.createTransport({ host: 'smtp.gmail.com', port: 587, secure: false, auth: { user: process.env.EMAIL_USER, pass: process.env.EMAIL_PASS, }, }); async function sendEmail() { const info = await transporter.sendMail({ from: '"My App" ', to: 'user@example.com', subject: 'Welcome to My App', text: 'Hello, welcome to our platform!', html: '

Hello

Welcome to our platform!

', }); console.log('Message sent:', info.messageId); } ``` ### HTML Email with Template ```typescript async function sendWelcomeEmail(user: { name: string; email: string }) { const html = `

Welcome, ${user.name}!

Thank you for joining our platform.

Get Started
`; await transporter.sendMail({ from: '"My App" ', to: user.email, subject: `Welcome, ${user.name}!`, html, }); } ``` ### Email with Attachments ```typescript async function sendEmailWithAttachment() { await transporter.sendMail({ from: '"Reports" ', to: 'manager@company.com', subject: 'Monthly Report', text: 'Please find the monthly report attached.', attachments: [ { filename: 'report.pdf', path: './reports/monthly-report.pdf', }, { filename: 'data.xlsx', content: Buffer.from('...'), // Buffer content }, { filename: 'logo.png', path: './assets/logo.png', cid: 'logo@myapp', // For embedding in HTML }, ], html: '

See attached report.

', }); } ``` ### OAuth2 Authentication (Gmail) ```typescript const transporter = nodemailer.createTransport({ service: 'gmail', auth: { type: 'OAuth2', user: process.env.GMAIL_USER, clientId: process.env.GOOGLE_CLIENT_ID, clientSecret: process.env.GOOGLE_CLIENT_SECRET, refreshToken: process.env.GOOGLE_REFRESH_TOKEN, }, }); ``` ### Email Queue with Rate Limiting ```typescript class EmailQueue { private queue: Array<() => Promise> = []; private processing = false; async add(emailFn: () => Promise) { this.queue.push(emailFn); this.process(); } private async process() { if (this.processing) return; this.processing = true; while (this.queue.length > 0) { const emailFn = this.queue.shift()!; await emailFn(); await new Promise(r => setTimeout(r, 1000)); // Rate limit } this.processing = false; } } ``` ## Tags `email`, `smtp`, `notification`, `communication`, `automation` ## Compatibility - Codex: ✅ - Claude Code: ✅ [View on SkillFed](https://skillfed.io/AIDotNet/MoYuCode/nodemailer) · [View on GitHub](https://github.com/AIDotNet/MoYuCode)