// guides

RSS to email daily digest: all your feeds in one morning email (free script, tested)

Turn several RSS or Atom feeds into one daily email, with an optional keyword filter and no repeats. One free Python file, standard library only, works with Gmail or any SMTP. Tested on live feeds.

Updated 2026-10-22 · about 10 minutes

Rather not set it up yourself? Describe your task in one sentence and we'll build and test it for you, free →

Steps

  1. Pick your feeds

    Collect the feed URLs you want in one email. Most blogs have one at /feed or /rss.xml; others worth trying: https://hnrss.org/frontpage (Hacker News), https://github.com/OWNER/REPO/releases.atom (new releases of any GitHub project), https://www.reddit.com/r/SUBREDDIT/.rss, and every YouTube channel. RSS 2.0 and Atom both work.

  2. Save the script

    Save the code below as rss_digest.py (or download rss_digest.py). It uses only the Python standard library, so there is nothing to pip install and no account or API key.

  3. Try it without sending anything

    Dry-run mode prints the email instead of sending it and doesn't remember anything, so you can tune feeds and keywords freely:

    RSS_FEEDS="https://hnrss.org/frontpage,https://github.com/n8n-io/n8n/releases.atom" \
      python3 rss_digest.py --dry-run

    It prints one line per feed (for example Release notes from n8n: 10 items, 8 new), then the subject and the items grouped by feed. Add RSS_KEYWORDS="ai,n8n" to keep only items whose title or summary contains one of those words.

  4. Add your email login

    Set the SMTP settings of the account that sends the digest. For Gmail, create an app password (Google Account → Security → 2-Step Verification → App passwords) and use it instead of your normal password:

    export SMTP_HOST=smtp.gmail.com SMTP_PORT=465
    export SMTP_USER=you@gmail.com SMTP_PASSWORD='your app password'
    export SMTP_FROM=you@gmail.com SMTP_TO=you@gmail.com
    export RSS_FEEDS="https://hnrss.org/frontpage,https://github.com/n8n-io/n8n/releases.atom"
    python3 rss_digest.py

    Port 465 uses SSL from the start. Any other port (usually 587) switches to STARTTLS. It prints Sent: ... when the mail went out and saves the item ids so they are never sent twice.

  5. Run it every morning

    Put the exports in a small shell file, then add one cron line (crontab -e) so it runs at 7:00:

    0 7 * * * . $HOME/rss.env && /usr/bin/python3 $HOME/rss_digest.py >> $HOME/rss_digest.log 2>&1

    On Windows or a Mac without cron, see our guide to running a Python script on a schedule. If nothing is new, no email is sent.

The script

#!/usr/bin/env python3
"""RSS to email daily digest. Standard library only. MIT licence.
Reads several RSS or Atom feeds, keeps new items (optionally only those matching your keywords)
and emails them to you as one message with a plain-text and an HTML part.
Settings come from environment variables (see tasktoagent.com/guides/rss-to-email-daily-digest/)."""
import os, re, sys, json, time, html, smtplib, ssl, urllib.request
import xml.etree.ElementTree as ET
from datetime import datetime, timezone
from email.message import EmailMessage
from email.utils import parsedate_to_datetime

FEEDS = [f.strip() for f in os.getenv("RSS_FEEDS", "").split(",") if f.strip()]
KEYWORDS = [k.strip().lower() for k in os.getenv("RSS_KEYWORDS", "").split(",") if k.strip()]
MAX_AGE_HOURS = int(os.getenv("RSS_MAX_AGE_HOURS", "48"))   # skip items older than this (0 = no limit)
MAX_ITEMS = int(os.getenv("RSS_MAX_ITEMS", "50"))           # per email, all feeds together
SEEN_FILE = os.getenv("RSS_SEEN_FILE", os.path.expanduser("~/.rss_digest_seen.json"))
SEEN_DAYS = 30                                               # how long sent ids are remembered

def local(tag):  # "{http://www.w3.org/2005/Atom}entry" -> "entry"
    return tag.rsplit("}", 1)[-1]

def child(el, *names):
    for c in el:
        if local(c.tag) in names:
            return c
    return None

def text(el, *names):
    c = child(el, *names)
    return (c.text or "").strip() if c is not None and c.text else ""

def when(s):
    if not s: return None
    try:
        d = parsedate_to_datetime(s)            # RSS: "Thu, 22 Oct 2026 19:05:00 +0000"
    except (TypeError, ValueError):
        try: d = datetime.fromisoformat(s.replace("Z", "+00:00"))   # Atom: "2026-10-22T19:05:00Z"
        except ValueError: return None
    return d if d.tzinfo else d.replace(tzinfo=timezone.utc)

def fetch(url):
    req = urllib.request.Request(url, headers={"User-Agent": "rss-digest/1.0 (+tasktoagent.com)"})
    with urllib.request.urlopen(req, timeout=20) as r:
        root = ET.fromstring(r.read())
    if local(root.tag) not in ("rss", "feed", "RDF"):
        raise ValueError(f"not an RSS or Atom feed (the page starts with <{local(root.tag)}>)")
    feed_title = text(child(root, "channel") if child(root, "channel") is not None else root, "title") or url
    items = []
    for el in root.iter():
        if local(el.tag) not in ("item", "entry"): continue
        link = text(el, "link")
        if not link:  # Atom: <link rel="alternate" href="..."/>
            for c in el:
                if local(c.tag) == "link" and c.get("rel", "alternate") == "alternate" and c.get("href"):
                    link = c.get("href"); break
        title = re.sub(r"\s+", " ", html.unescape(re.sub(r"<[^>]+>", "", text(el, "title")))) or link or "(no title)"
        summary = text(el, "description", "summary", "content")
        summary = re.sub(r"\s+", " ", html.unescape(re.sub(r"<[^>]+>", " ", summary))).strip()
        uid = text(el, "guid", "id") or link or title
        items.append({"id": url + "|" + uid, "title": title, "link": link, "summary": summary[:200],
                      "date": when(text(el, "pubDate", "published", "updated", "date")), "feed": feed_title})
    return feed_title, items

def matches(it):
    if not KEYWORDS: return True
    t = (it["title"] + " " + it["summary"]).lower()
    # whole words only, so "ai" doesn't match "email" and "go" doesn't match "google"
    return any(re.search(r"(?<![a-z0-9])" + re.escape(k) + r"(?![a-z0-9])", t) for k in KEYWORDS)

def render(items):
    txt, htm, last = [], [], None
    for it in items:
        if it["feed"] != last:
            txt.append(f"\n== {it['feed']} =="); htm.append(f"<h3>{html.escape(it['feed'])}</h3>")
            last = it["feed"]
        txt.append(f"- {it['title']}\n  {it['link']}")
        htm.append(f'<p><a href="{html.escape(it["link"])}">{html.escape(it["title"])}</a>'
                   + (f"<br><small>{html.escape(it['summary'])}</small>" if it["summary"] else "") + "</p>")
    return "\n".join(txt).strip(), "".join(htm)

def send(subject, txt, htm):
    msg = EmailMessage()
    msg["Subject"], msg["From"], msg["To"] = subject, os.environ["SMTP_FROM"], os.environ["SMTP_TO"]
    msg.set_content(txt); msg.add_alternative(f"<html><body>{htm}</body></html>", subtype="html")
    host, port = os.environ["SMTP_HOST"], int(os.getenv("SMTP_PORT", "465"))
    user, pw = os.getenv("SMTP_USER"), os.getenv("SMTP_PASSWORD")
    if port == 465:
        s = smtplib.SMTP_SSL(host, port, context=ssl.create_default_context(), timeout=30)
    else:
        s = smtplib.SMTP(host, port, timeout=30)
        if os.getenv("SMTP_STARTTLS", "1") == "1": s.starttls(context=ssl.create_default_context())
    with s:
        if user: s.login(user, pw)
        s.send_message(msg)

def main():
    dry = "--dry-run" in sys.argv
    if not FEEDS: raise SystemExit("Set RSS_FEEDS to one or more feed URLs, separated by commas.")
    seen = json.load(open(SEEN_FILE)) if os.path.exists(SEEN_FILE) else {}
    seen = {k: v for k, v in seen.items() if v > time.time() - SEEN_DAYS * 86400}
    now, new, failed = datetime.now(timezone.utc), [], []
    for url in FEEDS:
        try:
            name, items = fetch(url)
        except Exception as e:  # one broken feed must not stop the others
            print(f"Skipped {url}: {e}", file=sys.stderr); failed.append(url); continue
        fresh = [it for it in items if it["id"] not in seen and matches(it)
                 and not (MAX_AGE_HOURS and it["date"] and (now - it["date"]).total_seconds() > MAX_AGE_HOURS * 3600)]
        print(f"{name}: {len(items)} items, {len(fresh)} new", file=sys.stderr)
        new += fresh
    if len(failed) == len(FEEDS): raise SystemExit("All feeds failed; no email sent.")
    new = new[:MAX_ITEMS]
    if not new:
        print("Nothing new; no email sent."); return
    txt, htm = render(new)
    if failed:
        txt += "\n\nCould not read: " + ", ".join(failed)
        htm += "<p><small>Could not read: " + html.escape(", ".join(failed)) + "</small></p>"
    subject = f"RSS digest: {len(new)} new item{'s' if len(new) != 1 else ''} from {len({i['feed'] for i in new})} feed(s)"
    if dry:
        print(subject + "\n\n" + txt); return
    send(subject, txt, htm); print("Sent:", subject)
    for it in new: seen[it["id"]] = time.time()
    json.dump(seen, open(SEEN_FILE, "w"))

if __name__ == "__main__":
    main()

Settings

VariableWhat it doesDefault
RSS_FEEDSfeed URLs, separated by commasrequired
RSS_KEYWORDScomma-separated words, matched as whole words in the title and summary; empty = keep everythingempty
RSS_MAX_AGE_HOURSskip items older than this; 0 = no age limit (items without a date are always kept)48
RSS_MAX_ITEMSmaximum items per email, all feeds together50
RSS_SEEN_FILEwhere sent item ids are kept for 30 days~/.rss_digest_seen.json
SMTP_HOST, SMTP_PORTyour provider's SMTP server; 465 = SSL, other ports use STARTTLSport 465
SMTP_STARTTLSset to 0 only for a local test server without TLS1
SMTP_USER, SMTP_PASSWORDyour login (an app password for Gmail)
SMTP_FROM, SMTP_TOsender and recipient

What we tested

On 22 October 2026 we ran 12 checks with Python 3.13 against live public feeds, sending to a local test SMTP server (aiosmtpd on 127.0.0.1:2525) instead of a real inbox. Here is what happened:

TestResult
Dry run, 2 live feeds (hnrss.org/frontpage + n8n GitHub releases Atom)Hacker News: 20 items, 20 new; n8n releases: 10 items, 8 new (2 were older than 48 hours). Subject RSS digest: 28 new items from 2 feed(s). Nothing written to disk.
Same with RSS_KEYWORDS=ai,n8n12 of 28 kept: 7 from Hacker News, 5 from the n8n releases.
Whole-word matchOf the 30 items in both feeds, 13 contain the letters "ai" somewhere (Braille, Cash App account, n8n@2.45.2 release notes...) but only 8 contain the word "ai". The script keeps the 8.
3 other live feeds: xkcd (Atom), BBC Technology (RSS 2.0), r/n8n (Reddit Atom), RSS_MAX_AGE_HOURS=04 + 21 + 25 items read; the email stopped at 50 (the RSS_MAX_ITEMS default).
Send to a local SMTP serverOne email with a plain-text and an HTML part, 28 links under 2 feed headings; 28 ids saved to the seen file.
Second run straight after20 items, 0 new and 10 items, 0 new, then Nothing new; no email sent.
One feed returns 404, one is fineSkipped https://tasktoagent.com/no-such-feed.xml: HTTP Error 404: Not Found. The digest still listed the 20 Hacker News items, with a Could not read: ... line at the end naming both broken URLs (the other was a host that does not exist).
Every feed failsAll feeds failed; no email sent., exit code 1 (so cron logs it).
Broken XML (a bare & in a title)Skipped ...: not well-formed (invalid token): line 3, column 19; other feeds unaffected.
A web page instead of a feedSkipped ...: not an RSS or Atom feed (the page starts with <html>)
Wrong SMTP portConnectionRefusedError: [Errno 111] Connection refused; seen file not written, so nothing is lost.
STARTTLS against a server without TLSsmtplib.SMTPNotSupportedError: STARTTLS extension not supported by server. Use your provider's real host with port 465 or 587.

Why one email instead of a feed reader or a per-item alert?

Hosted RSS-to-email services usually send one email per item or cap free plans at a few feeds. A feed reader works only if you open it. One morning email with everything new, grouped by feed, is the lightest habit: if nothing changed, you get nothing. Because the script remembers what it sent, running it twice never repeats an item.

Only care about Hacker News? The Hacker News daily digest adds points thresholds and catches stories that never reach the front page. Want AI news summarised by an LLM? See the daily AI news digest. Prefer a chat? Use RSS to Telegram with a keyword filter or n8n RSS to Discord.

FAQ

Is there a free way to get an RSS feed by email?

Yes. This script is free (MIT licence), runs on any computer with Python 3, and sends through your own email account, so there is no service, plan or feed limit.

Can I combine several RSS feeds into one email?

Yes. Put all the URLs in RSS_FEEDS, separated by commas. The email groups items under each feed's name, up to RSS_MAX_ITEMS items in total.

Will it send the same item twice?

No. Every sent item id is kept for 30 days in the seen file. In our test, a second run straight after the first said Nothing new; no email sent. Dry runs don't update that file.

What happens if one feed is down?

The other feeds are still sent, and the email ends with a Could not read: line listing the broken ones. Only when every feed fails does the script exit with code 1 and send nothing.

Can I get it weekly instead of daily?

Yes. Set RSS_MAX_AGE_HOURS=168, raise RSS_MAX_ITEMS if needed, and change the cron line to 0 7 * * 1 for Monday mornings.

Does it work with Outlook or other email providers?

Yes, with any provider that allows SMTP: set SMTP_HOST and SMTP_PORT to the values your provider publishes. Gmail needs an app password, not your normal password.

Related guides

New guides

Want one built for your task?

Describe it in one sentence. We build it, test it and email it to you, usually within 24h. Free while we're in beta.

We'll only email you about your agent and TaskToAgent.