
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
send-email-api
Advanced tools
通过 Node.js 发送邮件,支持 SMTP 和 SendCloud
npm install send-email-api -S
const fs = require('fs')
const { sendMail } = require('send-email-api')
const run = async () => {
try {
const emailConfig = {
options: {
host: 'smtp.sendcloud.net',
auth: {
user: 'username',
pass: 'password',
}
},
from: 'test<test@sendcloud.com>',
}
const emailData = {
to: ['test@sendcloud.com'],
subject: '测试通过 smtp 发送带附件的邮件',
html: '<h3>hello world!</h3>',
text: 'hello world!',
attachments: [
{
filename: 'attachments-text.txt',
content: fs.readFileSync('./test/attachments-text.txt'),
},
{
filename: 'attachments-excel.xlsx',
content: fs.readFileSync('./test/attachments-excel.xlsx'),
},
],
}
const data = await sendMail(emailData, emailConfig)
console.log(data)
} catch (error) {
console.error(error)
}
process.exit()
}
run()
const fs = require('fs')
const { sendMailCloud } = require('send-email-api')
const run = async () => {
try {
const emailServerConfig = {
options: {
auth: {
user: 'api_user',
pass: 'api_key',
}
},
from: 'test<test@sendcloud.com>',
}
const emailData = {
to: ['test@sendcloud.com'],
subject: '测试通过 sendcloud 发送带附件的邮件',
html: '<h3>hello world!</h3>',
text: 'hello world!',
attachments: [
{
filename: 'attachments-text.txt',
content: fs.readFileSync('./test/attachments-text.txt'),
},
{
filename: 'attachments-excel.xlsx',
content: fs.readFileSync('./test/attachments-excel.xlsx'),
},
],
}
const emailUrl = 'https://api.sendcloud.net/apiv2/mail/send'
const data = await sendMailCloud(emailUrl, emailData, emailServerConfig)
console.log(data)
} catch (error) {
console.error(error)
}
process.exit()
}
run()
FAQs
send email by node.js, supports smtp and sendcloud
The npm package send-email-api receives a total of 1 weekly downloads. As such, send-email-api popularity was classified as not popular.
We found that send-email-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.