๐Ÿš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more โ†’
Socket
Book a DemoInstallSign in
Socket

send-email-api

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

send-email-api

send email by node.js, supports smtp and sendcloud

1.0.1
latest
Source
npm
Version published
Weekly downloads
5
150%
Maintainers
1
Weekly downloads
ย 
Created
Source

ๅ‘้€้‚ฎไปถ API

้€š่ฟ‡ Node.js ๅ‘้€้‚ฎไปถ๏ผŒๆ”ฏๆŒ SMTP ๅ’Œ SendCloud

Installation

npm install send-email-api -S

Usage

1. SMTP

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()

2. SendCloud

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()

API

  • sendMail: ้€š่ฟ‡ SMTP ๆ–นๅผๅ‘้€้‚ฎไปถ
  • sendMailCloud: ้€š่ฟ‡ SendCloud ๆ–นๅผๅ‘้€้‚ฎไปถ

ๅ‚่€ƒ

  • nodemailer
  • sendcloud

Keywords

email

FAQs

Package last updated on 02 Mar 2022

Did you know?

Socket

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.

Install

Related posts