# weighmail

Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

# weighmail

## An application to label your Gmail messages according to size

Author: Brian Neal 0.1.0 May 20, 2012 https://bitbucket.org/bgneal/weighmail/ New BSD License (see LICENSE.txt) https://bitbucket.org/bgneal/weighmail/issues

## Overview

weighmail is a program that analyzes your Gmail and applies labels to your messages according to their size. This is useful if you are close to reaching your quota as it allows you to quickly identify large messages. You have complete control over the rules used to create the labels.

## Installation

weighmail can be installed using Pip:

$pip install weighmail  Alternatively you can download a tarball and install with: $ python setup.py install


weighmail depends on the IMAPClient library. This library is automatically installed if you use Pip.

## Gmail Notes

In case it isn't clear, weighmail works with Gmail. You must have a Gmail account with IMAP support turned on. Please go into your settings and verify IMAP support is turned on before proceeding.

If you are using two-step verification on your Gmail account (and you really should be), you need to generate an application specific password for weighmail to use. In this case you will use an application specific password instead of your normal password when running weighmail.

## Usage

weighmail can accept options from a configuration file and/or the command-line. Command-line arguments always take precedence over options found in the configuration file.

### Command-Line Arguments

weighmail takes a fair number of arguments on the command-line. Most of these can be omitted however, as they all have sensible defaults. In fact, the simplest way to run weighmail is as follows:

$weighmail --labels big:1MB-5MB huge:5MB-10MB enormous:10MB-  This example demonstrates: • A big label will be applied to messages between 1 and 5 Megabytes • A huge label will be applied to messages between 5 and 10 Megabytes • An enormous label will be applied to messages 10 MB and bigger • Since no user or password options were supplied on the command-line, weighmail will interactively prompt for them. Neither will be echoed out for privacy reasons. To see a list of all command-line options: $ weighmail --help


Some notes on the options follows.

• The --config option is used to specify a configuration file that weighmail will read for options. Any options supplied on the command-line will override any options from this file. In particular, if you specify any label rules on the command-line, all label rules in the configuration file will be ignored.
• The --folder option can be used to specify which Gmail label to search for messages. This defaults to your All Mail label.
• The --user and --password options are used to specify which Gmail account to log into. If these are not supplied, and also omitted from a config file (or if no config file is being used), weighmail will prompt you for these options.
• The --labels argument is how you specify the rules for labeling your messages. See the sub-section below for more detail on this syntax.
• The --host, --port, and --nossl arguments are for advanced use only, and may in fact not work. The defaults should work for most people, and will connect you to imap.gmail.com port 993 using SSL.

#### The --labels argument syntax

To specify label rules on the command-line, use the following syntax:

$weighmail --labels name:min-max [name:min-max] ...  Where: • name is the name of the label. Note that Gmail labels cannot have spaces in them. • min and max specify the message size range in bytes. Either one, but not both, may be omitted (but the dash must remain). You may use the suffixes KB, MB, or GB to indicate kilobytes, Megabytes, or Gigabytes, respectively. Another example: $ weighmail --labels normal:-2MB big:2MB-7MB huge:7MB-


In all these examples the label ranges do not overlap. This does not have to be the case; overlapping ranges may be defined if desired.

### Configuration File

If you specify the --config=filename option on the command-line, weighmail will parse this file for options. Please see the included sample-weighmail.ini file for the syntax and option descriptions.

Again, note that command-line arguments take precedence over options found in the configuration file. If you specify any label rules on the command-line, all label rules in the configuration file are ignored.

### Thanks

A big thank-you to Menno Smits, the author of the IMAPClient library. This application would have been considerably more complicated if the awesome IMAPClient library did not exist.

# Recent activity

Commits by Brian Neal were pushed to bgneal/weighmail

1c0cfc9 - Added tag v0.1.0 for changeset 1e2f63b10b9f
1e2f63b - Remove download TODO.
8ebf36e - Remove TODO about pip in README.
7d1ca1f - Added a dependency on distribute in setup.py.
b63cce6 - First attempt at a setup.py for distribution.
330b4c2 - Added a sample .ini file.
8a523e5 - Added a test for the core weighmail function.
a3ef032 - Added tests for the functions in utils. Fixed bug with GB.
472b007 - First draft of a README file.
1315e39 - Add New BSD style license file.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.