工作总结 7.6

Node 后端发送邮件

公司官网后台需要一个注册申请功能,使用该轮子完成 SMTP 邮箱服务的调起。

eleith/emailjs: html emails and attachments to any smtp server with nodejs

使用 Express 服务器,对/sendemail进行发邮件操作

import { SMTPClient } from "emailjs";
import config from "./config.js";

// 设定邮件发送信息:发送邮箱(开启SMTP),密码,发送人姓名,收件人邮箱,发送人主机(SMTP服务器),发送人主机端口(SMTP服务器默认端口465),是否开启SSL
// 注:开启授权SMTP登陆码可以发送邮件
const {
  senderEmail,
  password,
  senderName,
  receiverEmail,
  host,
  port,
  SSLEnable,
} = config.email;

const client = new SMTPClient({
  user: `${senderEmail}`,
  password: `${password}`,
  host: `${host}`,
  port: port,
  ssl: SSLEnable,
});

async function sendEmail(emailContent) {
  try {
    const msg = await client.sendAsync({
      text: emailContent,
      from: `${senderName} <${senderEmail}>`,
      to: `${receiverEmail}`,
      subject: "Test Email",
    });
    console.log("email sent successfully. ", msg);
    return {
      status: "OK",
      code: 0,
    };
  } catch (e) {
    console.log("email sent failed. ", e);
    return {
      status: "Failed",
      code: 1,
    };
  }
}

export { sendEmail };

关于页面视频在线播放相关库

M3U8

FLV