如何使用 Node.js 邮箱服务进行自动化发送邮件 All In One

发布时间 2023-08-30 14:28:53作者: xgqfrms

如何使用 Node.js 邮箱服务进行自动化发送邮件 All In One

$ npm i -S nodemailer
"use strict";
const nodemailer = require("nodemailer");

const transporter = nodemailer.createTransport({
  host: "smtp.forwardemail.net",
  port: 465,
  secure: true,
  auth: {
    // TODO: replace `user` and `pass` values from <https://forwardemail.net>
    user: "REPLACE-WITH-YOUR-ALIAS@YOURDOMAIN.COM",
    pass: "REPLACE-WITH-YOUR-GENERATED-PASSWORD",
  },
});

// async..await is not allowed in global scope, must use a wrapper
async function main() {
  // send mail with defined transport object
  const info = await transporter.sendMail({
    from: '"Fred Foo ?" <foo@example.com>', // sender address
    to: "bar@example.com, baz@example.com", // list of receivers
    subject: "Hello ✔", // Subject line
    text: "Hello world?", // plain text body
    html: "<b>Hello world?</b>", // html body
  });

  console.log("Message sent: %s", info.messageId);
  // Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>

  //
  // NOTE: You can go to https://forwardemail.net/my-account/emails to see your email delivery status and preview
  //       Or you can use the "preview-email" npm package to preview emails locally in browsers and iOS Simulator
  //       <https://github.com/forwardemail/preview-email>
  //
}

main().catch(console.error);

https://nodemailer.com/

SMTP

cURL post

$ curl -XPOST "http://127.0.0.1:3000/v1/account/example/submit" \
    -H "Authorization: Bearer f77cf263b70488c7a35bf1539fd544a81a88711ff74326ce9793022df08d91b9" \
    -H "Content-type: application/json" \
    -d '{
      "from": {
        "name": "Andris Reinman",
        "address": "andris@example.com"
      },
      "to": [
        {
          "name": "Ethereal",
          "address": "andris@ethereal.email"
        }
      ],
      "subject": "Test message",
      "text": "Hello from myself!",
      "html": "<p>Hello from myself!</p>"
    }'

https://emailengine.app/sending-emails

image

demos


https://stackoverflow.com/questions/77004007/nodemailer-default-options-issue/77004119#77004119

(? 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

邮箱的 POP、SMTP、IMAP 服务器地址设置

  1. 如何查询某个邮箱发送邮件服务器地址端口
  2. 如何查询某个邮箱的接收邮件服务器地址和端口

image

POP3/SMTP/IMAP服务能让你在本地客户端上收发邮件

image

https://mail.163.com/js6/main.jsp

客户端协议

如何开启客户端协议?
什么是POP3、SMTP及IMAP?
IMAP和POP3有什么区别?
Oauth2.0 授权码超过限制怎么办?

https://help.mail.163.com/faq.do?m=list&categoryID=90

image

什么是 SMTP 认证?
SMTP 的全称是“Simple Mail Transfer Protocol”,即简单邮件传输协议。它是一组用于从源地址到目的地址传输邮件的规范,通过它来控制邮件的中转方式。SMTP 协议属于 TCP/IP 协议簇,它帮助每台计算机在发送或中转信件时找到下一个目的地。SMTP 服务器就是遵循 SMTP 协议的发送邮件服务器。
SMTP 认证,简单地说就是要求必须在提供了账户名和密码之后才可以登录 SMTP 服务器,这就使得那些垃圾邮件的散播者无可乘之机。
增加 SMTP 认证的目的是为了使用户避免受到垃圾邮件的侵扰。

https://mail.163.com/mailhelp/client.htm

https://qiye.163.com/help/client-profile.html

163 邮箱 host port

接收 pop / imap

接收邮件服务器: http://pop.163.com
接收端口: 110 / 995 (使用 SSL 时)

接收邮件服务器: http://imap.163.com
接收端口: 143 / 993 (使用 SSL 时)

发送 smtp

发送邮件服务器: http://smtp.163.com
发送端口: 25 / 465 / 994 (使用 SSL 时)

Cloudflare Email Routing

电子邮件路由

创建自定义电子邮件地址,在您不希望共享主要电子邮件地址时使用。

https://dash.cloudflare.com/

https://developers.cloudflare.com/email-routing/

free email

https://forwardemail.net/zh/private-business-email?pricing=true

refs

https://zhuanlan.zhihu.com/p/618281679



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 ?️,侵权必究⚠️!