node mailer & email bot
node mailer & email bot
https://github.com/nodemailer/nodemailer
https://www.npmjs.com/package/nodemailer
/* eslint no-console: 0 */
'use strict';
const nodemailer = require('../lib/nodemailer');
async function main() {
// Create a SMTP transporter object
let transporter = nodemailer.createTransport({
sendmail: true,
newline: 'windows',
logger: false
});
// Message object
let message = {
from: 'Andris <andris@kreata.ee>',
// Comma separated list of recipients
to: 'Andris Reinman <andris.reinman@gmail.com>',
bcc: 'andris@ethereal.email',
// Subject of the message
subject: 'Nodemailer is unicode friendly ',
// plaintext body
text: 'Hello to myself!',
// HTML body
html:
'<p><b>Hello</b> to myself <img src="cid:note@example.com"/></p>' +
'<p>Here\'s a nyan cat for you as an embedded attachment:<br/><img src="cid:nyan@example.com"/></p>',
// An array of attachments
attachments: [
// String attachment
{
filename: 'notes.txt',
content: 'Some notes about this e-mail',
contentType: 'text/plain' // optional, would be detected from the filename
},
// Binary Buffer attachment
{
filename: 'image.png',
content: Buffer.from(
'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/' +
'//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U' +
'g9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC',
'base64'
),
cid: 'note@example.com' // should be as unique as possible
},
// File Stream attachment
{
filename: 'nyan cat .gif',
path: __dirname + '/assets/nyan.gif',
cid: 'nyan@example.com' // should be as unique as possible
}
]
};
let info = await transporter.sendMail(message);
console.log('Message sent successfully as %s', info.messageId);
}
main().catch(err => {
console.error(err.message);
process.exit(1);
});

weather api
fetch("https://tianqi.moji.com/weather/china/shanghai/pudong-new-district", { mode: "no-cors", })
.then(res => {
console.log(`res =`, res)
return res.text();
})
.then(html => {
console.log(`html =`, html)
const parser = new DOMParser();
const dom = parser.parseFromString(html, "text/html");
console.log(`html dom =`, dom)
// api data
const todayWeather = dom.querySelectorAll(`.days`)[0].innerText.replace(/[\r\n]/ig, `,`).split(`,`);
// ["今天", "阴", "21° / 30°", "南风", "4-5级", "55 良"]
console.log(`todayWeather api datas =`, todayWeather);
})
.catch(err => {
console.error('Failed to fetch html page content!', err);
});
demo
https://segmentfault.com/a/1190000012251328
https://github.com/growvv/weather-bot
https://github.com/growvv/weather-bot/blob/master/.github/workflows/SendMail.yml
refs
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
node mailer & email bot的更多相关文章
- Postman SMTP 存在跨站脚本(XSS)漏洞,请换用Post SMTP Mailer/Email Log
Postman SMTP 是一个安装量超过10W的WordPress插件,但是已经2年多没有更新,2017年6月29日,被发现存在跨站脚本(XSS)漏洞(查看详情),并且作者一直没有更新,所以被从Wo ...
- HCW 19 Team Round (ICPC format) B. Beggin' For A Node(树的重心,交互题)
B. Beggin' For A Node time limit per test2.0 s memory limit per test256 MB inputstandard input outpu ...
- JS打字效果的动态菜单代码分享
这篇文章主要介绍了JS打字效果的动态菜单,推荐给大家,有需要的小伙伴可以参考下. 这是一款基于javascript实现的打字效果的动态菜单特效代码,分享给大家学习学习. 小提示:浏览器中如果不能正常运 ...
- Qt XML读取写入操作
XML(eXtensible Markup Language,可扩展标记语言)是普通用于数据交换和数据存储的一种多用途文本文件格式: SVG(可标量矢量图形)XML格式,QtSvg模块提供了可用于载入 ...
- HDU - 1584 IDA*
思路:裸的IDA*,估计当前状态至少需要多少距离才能达到目标状态,剪枝即可.每一墩牌只需记录其最上面和最下面的牌型即可完成移动. AC代码 #include <cstdio> #inclu ...
- T-codes & Rarely Seen Tables(Updated from previous note)
T-codes C CO CO01/02/03:Production Order CG CG3Y:Download file from server,never used this before CM ...
- prisma 服务器端订阅试用
graphql 协议是支持数据的实时订阅功能的(一般基于websocket 进行实现) prisma 支持客户端订阅以及服务器端订阅(类似webhook),可以方便将 数据推送后端服务 目的 pr ...
- 数据库:XML,解析Dom4J
package com.itheima.util; import java.io.FileOutputStream; import java.net.URL; import org.dom4j.Doc ...
- babeljs源码
babel.min.js!function(e,t){"object"==typeof exports&&"object"==typeof mo ...
随机推荐
- LOJ10069 TREE
题目描述 原题来自:2012 年国家集训队互测 给你一个无向带权连通图,每条边是黑色或白色.让你求一棵最小权的恰好有 need 条白色边的生成树.题目保证有解. 输入格式 第一行 V,E,need 分 ...
- 提高效率的Linux命令
提高效率的Linux命令 一.fc 二.disown 三.Ctrl + x +e 四.!! 两个感叹号 五.一次创建多个目录或文件 六.tee 七.删除从开头到光标处的命令文本 八.删除从光标到结尾处 ...
- 封装各种生成唯一性ID算法的工具类
/** * Copyright (c) 2005-2012 springside.org.cn * * Licensed under the Apache License, Version 2.0 ( ...
- 2020第十一届蓝桥杯第二场JavaB组
第一题:门牌制作(624) 题目大意: 判断1到2020里面共有多少个'2': 解析: 本题简而言之就是找'2'这一个数 第一种方法:遍历将其转换为字符然后再遍历寻找 第二种方法:直接用数值的方法进行 ...
- Testing Round #16 (Unrated)
比赛链接:https://codeforces.com/contest/1351 A - A+B (Trial Problem) #include <bits/stdc++.h> usin ...
- Grakn Forces 2020
比赛链接:https://codeforces.com/contest/1408 A. Circle Coloring 题意 给出三个长为 $n$ 的序列 $a,b,c$,对于每个 $i$,$a_i ...
- Codeforces Round #604 (Div. 2) A. Beautiful String(贪心)
题目链接:https://codeforces.com/contest/1265/problem/A 题意 给出一个由 a, b, c, ? 组成的字符串,将 ? 替换为 a, b, c 中的一个字母 ...
- Codeforces 102394I Interesting Permutation 思维
题意: 你有一个长度为n的序列a(这个序列只能使用[1,n]区间内的数字,每个数字只能使用一次),通过a序列可以构造出来三个相同长度的序列f.g.h For each 1≤i≤n, fi=max{a1 ...
- 一张图解决ThreadLocal
一张图解决ThreadLocal 一.前言 年底梳理知识体系时,研究了一下ThreadLocal的源码,整理了一张核心图. 想着,都走到这一步了,那就写一篇深度解读的文章吧.看过我之前文章的小伙伴都知 ...
- Redis-sentinel 哨兵(HA)
Sentinel 介绍 Redis-Sentinel 是 Redis 官方推荐的高可用性(HA)解决方案,当用 Redis 做 Master-slave 的高可用方案时,假如Master 宕机了,Re ...