Automatically send sponsorship emails using Google Docs, Google Sheets, and MailGun.
sponsor-emails
can be downloaded as a Python package from the Actions tab, or it can be installed directly with Pip.
# Pip from source
pip install git+https://github.com/WaffleHacks/sponsor-emails.git
# Pip from downloaded wheel
pip install ~/Downloads/sponsor_emails_3.9.whl
# Running
sponsor-emails --help
You can also use Pipx to install and run sponsor-emails
in a virtual environment.
pipx run --spec git+https://github.com/WaffleHacks/sponsor-emails.git sponsor-emails --help
Once you have sponsor-emails
installed, run sponsor-emails validate
to generate the default configuration.
This should error as there are some necessary details you will need to fill in, such as your GCP and MailGun credentials.
- Register for a Google Cloud Platform account, if you don't already have on
- Enable the APIs for Google Docs, Google Drive, and Google Sheets
- Navigate to the APIs & Services page
- Click on "Enable APIs and Services" near the top
- Search for and enable the "Google Docs API", "Google Drive API", and "Google Sheets API"
- Create a Service Account to access the APIs with
- Navigate to "Credentials" on the APIs & Services page
- Click on "Create Credentials" near the top and select "Service account"
- Fill out the name, id, and, optionally, the description; then click "Done"
- Click on "Manage service accounts" on the right by the "Service Accounts" header
- Click the three dots (
⋮
) near your recently created service account and select "Manage keys" - Click on "Add Key", then select "Create new key" and use the JSON format
- Save the downloaded key somewhere safe and remember its location for later
- Share any Google Docs or Google Sheets with the service account's email using the standard "Share" button
- Copy the path to the service account file into the
credentials.gcp
inconfig.json
field. Ex:
{
"credentials": {
"gcp": "/path/to/your/service-account.json"
}
}
- Register for a MailGun account, if you don't already have one
- Add your domain if you haven't already, following the offical docs
- You can use the automatically added sandbox domain, but it should only be used for testing
- Get your private API key from the "API Keys" page
- Go to the "API Keys" page under "Settings" in the sidebar
- Copy the key under "Private API key"
- Paste the API key and domain into
config.json
atcredentials.mailgun_api_key
andcredentials.mailgun_domain
respectively. Ex:
{
"credentials": {
"mailgun_domain": "your.domain.com",
"mailgun_api_key": "afffeag-your-api-key-afgjo"
}
}
- Configure the template document
- Copy the URL for your Google Doc and paste it into
template.url
- Add your placeholders for the company's name, contact's name, and sender's name under
template.placeholders
. These are all case-sensitive.
- Copy the URL for your Google Doc and paste it into
- Configure the sponsors spreadsheet
- Copy the URL for your Google Sheet and paste it into
sponsors.url
- Put the name of the worksheet (ex. "Sheet 1") into
sponsors.sheet
- Put the statuses for your messages into
sponsors.statuses
.- The
sponsors.statuses.sent
will be set when a message gets successfully sent - The
sponsors.statuses.pending
will be set when a message fails to send - If the status is not equal to
sponsors.statuses.pending
before sending, the message will not be sent
- The
- Set the column headers in
sponsors.headers
to the respective columns in your spreadsheet - If you have a sponsorship package (example), put copy the path to
sponsors.package
, otherwise set it tonull
- Copy the URL for your Google Sheet and paste it into
- Configure the senders spreadsheet
- Copy the URL for your Google Sheet and paste it into
senders.url
- Put the name of the worksheet (ex. "Sheet 2") into
senders.sheet
- Set
senders.header
to the name of the column with the organizer's first and last names - Set
senders.reply_to
to the email that messages should reply to
- Copy the URL for your Google Sheet and paste it into
To ensure your configuration is correct, run sponsor-emails validate
.
You will need to install Poetry and a recent version of Python (3.8+).
Then install the dependencies with poetry install
.
The application entrypoint is in sponsor_emails/cli.py
.