Last active
August 31, 2019 07:55
-
-
Save BirkhoffLee/029289cb03c38039773e85c278693b5c to your computer and use it in GitHub Desktop.
daily RSS feed to mailgun email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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