Emails
- First column is names (see special names in
emailer/name.py
) - Second column is default values for each name
- Next column(s) is one email each, with values replaced by default if empty
- First column is names (see special names in
Recipients
- Each row is one recipient made up of:
- Groups they are members of (e.g. Active, Dryrun)
- Any number of highlights (this can be a name in the
Emails
sheet)
- Each row is one recipient made up of:
usage: email [-h] [-c CONFIG_DIR] [-k [KEY_NAMES [KEY_NAMES ...]]]
[--all-keys] [-d DATE] [-v] [-V] [--sample-config] [--skip-send]
[--save-sheet-to SAVE_SHEET_TO] [--stdin] [--stdout-markdown]
[--stdout-email] [--active | --dryrun | --test]
optional arguments:
-h, --help show this help message and exit
-c CONFIG_DIR, --config-dir CONFIG_DIR
Directory containing config file. Default is current
working directory.
-k [KEY_NAMES [KEY_NAMES ...]], --key-names [KEY_NAMES [KEY_NAMES ...]]
Key name(s) matching key(s) in the config.
--all-keys Run for all available keys in config.
-d DATE, --date DATE Date for which to send emails (YYYY-MM-DD). The
default is today.
-v, --verbose Display more logging output
-V, --version Print the current emailer module version and exit.
--sample-config Print a sample config. Save as emailer.json or
.emailer.json and exit.
--skip-send Avoid actually sending emails, useful for testing.
--save-sheet-to SAVE_SHEET_TO
Save the sheet into the following JSON file.
--stdin Use STDIN to get the sheet data, instead of directly
from Google Sheets.
--stdout-markdown Print a JSON array of unhighlighted email,still in
markdown.
--stdout-email Print a JSON array all highlighted email messages.
--active Send emails to all active recipients.
--dryrun Send emails one day early to dryrun recipients.
--test Send emails only to test recipients.
Send a message for today's date to all Active recipients on the list mykey
:
python -m emailer -k mykey --active
See what would happen if today's email went out, but don't actually send email:
python -m emailer -k mkey --active --verbose --skip-send
Send a dryrun version of tomorrow's email to DryRun recipients:
python -m emailer -k mykey --dryrun
Send a dryrun version of a specific date to the DryRun recipients.
python -m emailer -k mykey --dryrun -d 2019-10-20
Provide a cached json sheet, and return a list of email (doesn't send or lookup anything on the server):
cat sheet.json | python -m emailer -k mkey --active --skip-send --stdin --stdout-email
[
"Subject: Schedule for 2019-10-26\nFrom: Schedule Emailer <me@example.com>\nTo: alice@example.com\nReply-To: Robert Wallis <robert@example.com>\nContent-Type: text/html; charset=\"utf-8\"\nContent-Transfer-Encoding: quoted-printable\nMIME-Version: 1.0\n\n<p>=No Meeting Today</p>\n",
"Subject: Schedule for 2019-10-26\nFrom: Schedule Emailer <me@example.com>\nTo: bob@example.com\nReply-To: Robert Wallis <robert@example.com>\nContent-Type: text/html; charset=\"utf-8\"\nContent-Transfer-Encoding: quoted-printable\nMIME-Version: 1.0\n\n<p>=No Meeting Today</p>\n",
]
Get the sheet from Google Sheets and cache it.
python -m emailer -k mykey --test --skip-send --save-sheet-to sheet.json
- Enable the Gmail
and Sheets APIs.
- Download
credentials.json
to be used in the config file.
- Download
- Set up a config json file using
--sample-config
- Save the result as
emailer.json
in home dir. - The spreadsheet key is the long entry in the URL:
https://docs.google.com/spreadsheets/<key>/edit
- Save the result as
- In case of Google API errors, check the GSuite Dashboard.
pipenv
can be installed using pipx.- For packaging,
tox
andtwine
are also necessary.
- For packaging,
- Use
make init
to initialize the dev virtual environment. - Use
make
to run all tests, including lint and coverage. - Use
pipenv update --dev
to updatePipfile.lock
. - Use
make yapf
to automatically fix python formatting.