Git Product home page Git Product logo

email-feed's Introduction

Code Climate Issue Count License python3.x

email-feed

email-feed is a script that scans email and creates an RSS feed for unread messages. It only shares titles, it doesn't reveal message contents. It should be run as a cronjob.

Getting Started

  1. Rename email_feed.cfg.sample to email_feed.cfg
  2. Customize the variables in email_feed.cfg (More on this below.)
  3. Set up a cronjob that runs email_feed every day.
  4. Set up something to maintain the size of its log file.

What It Does

It scans an email account and creates an RSS feed for unread messages. This is useful for any email accounts that you rarely check if you use a feed reader.

For each unread email, it'll create a feed item like so:

<item>
  <title>
    [CoinBase] Bitcoin transaction complete.
  </title>
  <pubDate>Fri, 16 Nov 2012 07:23:52 +0000 (UTC)</pubDate>
  <link>https://webmail.yourdomain.com/</link>
  <guid isPermaLink="false">7aa13ff7fc1542e3c609aa41fbbc6bc61cb1f4e4</guid>
  <description>
    "[CoinBase] Bitcoin transaction complete." sent on Fri, 16 Nov 2012 07:23
  </description>
</item>

The logfile it writes looks something like this:

2012-10-08 13:00  1s OK (Wrote 1 new item.)
2012-10-09 13:00  0s OK
2012-10-10 13:00  1s OK (Wrote 3 new items.)
2012-10-11 13:00  0s OK

The RSS feed it writes validates at the feed validation service.

Customizing email_feed.cfg

email_feed.cfg looks like this:

[main]
name = John Doe
url_base = yourdomain.com
logfile = logfile.log
rss_base = email_feed
[imap]
mailbox = mail.yourdomain.com
webmail = https://%(mailbox)s
user = [email protected]
password = mooltipass

The Main Section

This section refers to stuff like the name and location of the new RSS file.

name: The name of the person to whom the email feed belongs.
url_base: The base of the URL that the RSS feed is at.
logfile: The name of the logfile.
rss_base: The base filename of the RSS file. '.xml' will be appended to the end.

Given the example above, the complete URL for the feed would be http://yourdomain.com/email_feed.xml.

The IMAP Section

This section refers to the mailbox that the script will read to create the feed.

mailbox: The IMAP address of the email server.
webmail: The address of the server's web interface.
user: The email address of the account to watch.
password: The IMAP password.

Maintaining the size of the logfile

To restrict the size of your logfile, you should use the mechanism provided by your operating system. But if you want to roll your own, putting something like the following in a cronjob will work, too.

find log/ -maxdepth 1 -name \*\.log -type f ! -executable -print0 | \
xargs -0 -I{} sh -c 'MAX=200; if [ $(wc -l < "{}") -gt $MAX ]; then \
TMPF=$(mktemp) && tail -$MAX "{}" > $TMPF && chmod --reference="{}" $TMPF && mv $TMPF "{}"; fi'

Is it any good?

Yes.

Debugging

Run the command with the --verbose flag for verbose logging.

Licence

This software uses the MIT License.

email-feed's People

Contributors

dblume avatar

Stargazers

Elsie Hupp avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

elsiehupp

email-feed's Issues

Sometimes subject is bytes not string, causing exception.

Traceback (most recent call last):
File "/home/pi/email_feed.py", line 133, in
main(web_dir)
File "/home/pi/email_feed.py", line 111, in main
update_status = write_feed(feed_dir, feed_items)
File "/home/pi/email_feed.py", line 62, in write_feed
title = html.escape(title)
File "/usr/lib/python3.4/html/init.py", line 19, in escape
s = s.replace("&", "&") # Must be done first!
TypeError: expected bytes, bytearray or buffer compatible object

PyPI packaging and distribution?

I was able to figure out PyPI packaging and distribution for liblarch (though none of the maintainers got around to setting up PyPI account to actually pull the trigger). Is this something you would be open to me helping you with?

(I ask because PyPI is just much more convenient than manually downloading or cloning for production use cases and dependency management.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.