Skip to content

Instantly share code, notes, and snippets.

@BirkhoffLee
Last active August 31, 2019 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BirkhoffLee/029289cb03c38039773e85c278693b5c to your computer and use it in GitHub Desktop.
Save BirkhoffLee/029289cb03c38039773e85c278693b5c to your computer and use it in GitHub Desktop.
daily RSS feed to mailgun email
let d = new Date()
d.setDate(d.getDate() - 1)
const date = d.toISOString().split('T')[0]
const RssToEmail = require('rss-to-email')
const config = {
accentColor: "red",
header: {
link: "",
title: "RSS Feed"
},
intro: "",
feeds: [
{
title: "jlelse's Blog",
url: "https://jlelse.blog/index.xml",
publishedSince: date
},
{
title: "Brendan Abolivier",
url: "https://brendan.abolivier.bzh/index.xml",
publishedSince: date
},
{
title: "Ctrl blog",
url: "https://feed.ctrl.blog/latest.atom",
publishedSince: date
},
{
title: "CodeSections",
url: "https://www.codesections.com/rss.xml",
publishedSince: date
},
{
title: "davd.io",
url: "https://www.davd.io/index.xml",
publishedSince: date
},
{
title: "Donn Felker",
url: "https://feeds.feedburner.com/donnfelker",
publishedSince: date
},
{
title: "tonsky.me",
url: "http://tonsky.me/blog/atom.xml",
publishedSince: date
},
{
title: "Victoria Drake",
url: "https://victoria.dev/verbose/index.xml",
publishedSince: date
}
],
outro: "",
templateUrl: "https://raw.githubusercontent.com/portable-cto/rss-to-email/master/src/templates/default.mjml"
}
const rssToEmail = RssToEmail(config)
rssToEmail.getEmail('html').then((email) => {
let mailgun = require('mailgun-js')({
apiKey: "xxxxxx",
domain: "example.com"
})
let data = {
from: 'RSS Feed <feed@example.com>',
to: 'admin@example.com',
subject: 'RSS Feed of the Day',
text: email
}
mailgun.messages().send(data, function (error, body) {
console.log(body)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment