gmail-draft-creator


Namegmail-draft-creator JSON
Version 1.3.1 PyPI version JSON
download
home_pagehttps://github.com/iloveitaly/gmail-draft-creator
SummarySimple tool to take a CSV and a template and create drafts in your Gmail. Can be used as a command line tool, or as a library.
upload_time2024-05-09 15:42:40
maintainerNone
docs_urlNone
authorMichael Bianco
requires_python<4.0,>=3.9
licenseMIT
keywords gmail email gmail-api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Gmail Drafter: Create Mail Merge Drafts

Simple tool to take a CSV and a template and create drafts in your Gmail. Useful for sending emails to large-ish numbers
of people where you want to slightly customize the emails for each user. You can quickly run through drafts, customize it, and send.

## Installation

```shell
pip install -U gmail-draft-creator
```

## Usage

```shell
Usage: gmail-draft-creator [OPTIONS]

Options:
  --csv PATH       Path to the CSV file.  [required]
  --template PATH  Path to the template file.  [required]
  --subject TEXT   Subject for the email drafts.
  --dry-run        Run script without creating drafts.
  --help           Show this message and exit.
```

You can also import the `create_draft` function and use it in your own scripts.

### CSV Files

Must contain an `email` column (case insensitive).

Each column in the CSV is passed as a parameter to the provided template. The column name is stripped of whitespace, lowercased, and stripped all non-alpha characters. For example, a column named `First Name` would be passed as `$firstname` in the template.

### Template Files

You can include subject line and variables in the template file:

```text
Subject: Hello $NAME

Hi, here's another ${REASON} why I'm emailing you.
```

### CSV Files

A CSV file that would work with this template might be something like this:

```
Email,Name,Reason,OtherColumn,...
joe@test.com,Joe,reminder,...
jeff@email.com,Jeff,sales pitch,...
```

## Setup

You need to create a "OAuth 2.0 Client IDs" which has to be done with a Google Workspace (gsuite). This will not work on a personal gmail account (unless you create a app on a workspace and add your personal account as a test account).

### Generating a Gmail API Token

1. Navigate to the Google Cloud Console. https://console.developers.google.com/
2. Create a new project or select an existing one.
3. Go to "APIs & Services" -> "Library" and enable the Gmail API.
4. Navigate to "APIs & Services" -> "Credentials".
5. Click "Create Credentials" -> "OAuth client ID".
6. Select "Desktop app" as the application type, then click "Create".
7. Download the JSON file, rename it to `credentials.json`, and place it in the root of this project.
8. Run the script and oauth into your account

If you want to edit scopes on an existing application, you can:

1. OAuth Consent Screen
2. Edit
3. Continue to step 2
4. Add or remove scopes
5. Add scopes and save

#### Credential Scopes Needed

Two main scopes are required for this:

* `https://www.googleapis.com/auth/gmail.compose`
* `https://www.googleapis.com/auth/gmail.readonly`

Some other scopes I'd add so you can reuse the credentials in other projects, [like gmailctl](https://github.com/mbrt/gmailctl) or calendar scripts:

* `https://www.googleapis.com/auth/calendar.readonly`
* `https://www.googleapis.com/auth/calendar.event`
* `https://www.googleapis.com/auth/gmail.labels`
* `https://www.googleapis.com/auth/gmail.settings.basic`

## TODO

- [ ] add credentials as a command line argument
- [ ] add serialized token as a CLI argument

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/iloveitaly/gmail-draft-creator",
    "name": "gmail-draft-creator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "gmail, email, gmail-api",
    "author": "Michael Bianco",
    "author_email": "mike@mikebian.co",
    "download_url": "https://files.pythonhosted.org/packages/82/03/819c39ebd60f6912a7b0969ef88fa98f9ec75e256ca37f73d27730a42418/gmail_draft_creator-1.3.1.tar.gz",
    "platform": null,
    "description": "# Gmail Drafter: Create Mail Merge Drafts\n\nSimple tool to take a CSV and a template and create drafts in your Gmail. Useful for sending emails to large-ish numbers\nof people where you want to slightly customize the emails for each user. You can quickly run through drafts, customize it, and send.\n\n## Installation\n\n```shell\npip install -U gmail-draft-creator\n```\n\n## Usage\n\n```shell\nUsage: gmail-draft-creator [OPTIONS]\n\nOptions:\n  --csv PATH       Path to the CSV file.  [required]\n  --template PATH  Path to the template file.  [required]\n  --subject TEXT   Subject for the email drafts.\n  --dry-run        Run script without creating drafts.\n  --help           Show this message and exit.\n```\n\nYou can also import the `create_draft` function and use it in your own scripts.\n\n### CSV Files\n\nMust contain an `email` column (case insensitive).\n\nEach column in the CSV is passed as a parameter to the provided template. The column name is stripped of whitespace, lowercased, and stripped all non-alpha characters. For example, a column named `First Name` would be passed as `$firstname` in the template.\n\n### Template Files\n\nYou can include subject line and variables in the template file:\n\n```text\nSubject: Hello $NAME\n\nHi, here's another ${REASON} why I'm emailing you.\n```\n\n### CSV Files\n\nA CSV file that would work with this template might be something like this:\n\n```\nEmail,Name,Reason,OtherColumn,...\njoe@test.com,Joe,reminder,...\njeff@email.com,Jeff,sales pitch,...\n```\n\n## Setup\n\nYou need to create a \"OAuth 2.0 Client IDs\" which has to be done with a Google Workspace (gsuite). This will not work on a personal gmail account (unless you create a app on a workspace and add your personal account as a test account).\n\n### Generating a Gmail API Token\n\n1. Navigate to the Google Cloud Console. https://console.developers.google.com/\n2. Create a new project or select an existing one.\n3. Go to \"APIs & Services\" -> \"Library\" and enable the Gmail API.\n4. Navigate to \"APIs & Services\" -> \"Credentials\".\n5. Click \"Create Credentials\" -> \"OAuth client ID\".\n6. Select \"Desktop app\" as the application type, then click \"Create\".\n7. Download the JSON file, rename it to `credentials.json`, and place it in the root of this project.\n8. Run the script and oauth into your account\n\nIf you want to edit scopes on an existing application, you can:\n\n1. OAuth Consent Screen\n2. Edit\n3. Continue to step 2\n4. Add or remove scopes\n5. Add scopes and save\n\n#### Credential Scopes Needed\n\nTwo main scopes are required for this:\n\n* `https://www.googleapis.com/auth/gmail.compose`\n* `https://www.googleapis.com/auth/gmail.readonly`\n\nSome other scopes I'd add so you can reuse the credentials in other projects, [like gmailctl](https://github.com/mbrt/gmailctl) or calendar scripts:\n\n* `https://www.googleapis.com/auth/calendar.readonly`\n* `https://www.googleapis.com/auth/calendar.event`\n* `https://www.googleapis.com/auth/gmail.labels`\n* `https://www.googleapis.com/auth/gmail.settings.basic`\n\n## TODO\n\n- [ ] add credentials as a command line argument\n- [ ] add serialized token as a CLI argument\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simple tool to take a CSV and a template and create drafts in your Gmail. Can be used as a command line tool, or as a library.",
    "version": "1.3.1",
    "project_urls": {
        "Homepage": "https://github.com/iloveitaly/gmail-draft-creator"
    },
    "split_keywords": [
        "gmail",
        " email",
        " gmail-api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "52d75cf962bf55e89448a37a1847e22cb5ccbee150317ff7e6d7a521ff6bca61",
                "md5": "32daef66ab5b3925f6f4e1c431708343",
                "sha256": "1243b50319810f5c3f553db6ac2204a1804860cac43ce663c21cbbf32000d584"
            },
            "downloads": -1,
            "filename": "gmail_draft_creator-1.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "32daef66ab5b3925f6f4e1c431708343",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 5631,
            "upload_time": "2024-05-09T15:42:38",
            "upload_time_iso_8601": "2024-05-09T15:42:38.274327Z",
            "url": "https://files.pythonhosted.org/packages/52/d7/5cf962bf55e89448a37a1847e22cb5ccbee150317ff7e6d7a521ff6bca61/gmail_draft_creator-1.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8203819c39ebd60f6912a7b0969ef88fa98f9ec75e256ca37f73d27730a42418",
                "md5": "05438613395985d7ca0fe11849e342ed",
                "sha256": "5eb23ab29ea40f78e101113fa3a14ace97b33cac276a6f7726cacd7c6507cfb4"
            },
            "downloads": -1,
            "filename": "gmail_draft_creator-1.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "05438613395985d7ca0fe11849e342ed",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 5050,
            "upload_time": "2024-05-09T15:42:40",
            "upload_time_iso_8601": "2024-05-09T15:42:40.063084Z",
            "url": "https://files.pythonhosted.org/packages/82/03/819c39ebd60f6912a7b0969ef88fa98f9ec75e256ca37f73d27730a42418/gmail_draft_creator-1.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-09 15:42:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "iloveitaly",
    "github_project": "gmail-draft-creator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "gmail-draft-creator"
}
        
Elapsed time: 0.25594s