如何在指定日期发送存储在数据库中的电子邮件。节点

How to send an email at specified date which is stored in database. Nodejs

我想向存储在数据库中的用户发送电子邮件。对于每个用户,我们定义一个特定的日期。到达该日期时,系统会自动向该用户发送一封电子邮件。

你的问题被否决了,因为你的答案已经存在于文档中。提及交货时间为 o:deliverytime.

Example from the documentation:

var mailgun = require("mailgun-js");
var api_key = 'YOUR_API_KEY';
var DOMAIN = 'YOUR_DOMAIN_NAME';
var mailgun = require('mailgun-js')({apiKey: api_key, domain: DOMAIN});

var data = {
  from: 'Excited User <me@samples.mailgun.org>',
  to: 'bar@example.com',
  subject: 'Scheduled Message',
  text: 'Testing some Mailgun awesomeness!',
  "o:deliverytime": 'Fri, 6 Jul 2017 18:10:10 -0000'
};

mailgun.messages().send(data, function (error, body) {
  console.log(body);
});

在 Stack Overflow 上发帖前请先查看文档。

可以在以下位置找到文档:Mailgun Documentation

我使用 cron-node 包每 24 小时发送一次电子邮件工作

const cron = require('node-cron');
// scheduling do a job in the node-cron
cron.schedule('0 0 0 * * *', () => {
  schedule.run_mid_night();
});