dc-mailer


Namedc-mailer JSON
Version 0.1.5 PyPI version JSON
download
home_pageNone
SummaryA simple email alert utility for Python projects
upload_time2025-02-04 04:23:22
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT License Copyright (c) 2025 Denise Case Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords email alert notification
VCS
bugtrack_url
requirements pip setuptools wheel build twine pytest
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dc-mailer

> Send an email alert using Python and Gmail

## Requirements

- Python 3.11+ (required for reading toml files)
- A configured Gmail Account (see below)

---

## Step 1. Install this Module

Run

```
pip install dc-mailer
```

Or: add `dc-mailer` to requirements.txt and install. 

---

## Step 2. Configure Application Settings

### Local Development
For local development, we can configure our settings with a file.
First, add .env.toml to .gitignore to keep it from being published.
Then, create a .env.toml file in your project directory with the following.
```
outgoing_email_host = "smtp.gmail.com"
outgoing_email_port = 587
outgoing_email_address = "youremail@gmail.com"
outgoing_email_password = "aaaabbbbccccdddd"
```

### GitHub Action Deployments
In a deployment environment like GitHub Actions, the .env.toml file won't be available. Instead, you'll need to set the configuration variables as environment variables.

First, add the following secrets to your GitHub repository:

1. Navigate to your repository on GitHub.
2. Click on Settings > Secrets and variables > Actions.
3. Click on New repository secret and add the following secrets:
    - OUTGOING_EMAIL_HOST: Set this to "smtp.gmail.com".
    - OUTGOING_EMAIL_PORT: Set this to 587.
    - OUTGOING_EMAIL_ADDRESS: Set this to your email address (e.g., "your-email@gmail.com").
    - OUTGOING_EMAIL_PASSWORD: Set this to your application password.

Next, reference these secrets in your GitHub Actions workflow. 
For an example, see [this deploy.yml](https://github.com/denisecase/kafka-producer-earthquake/blob/main/.github/workflows/deploy.yml).

---

## Step 3. Configure Gmail 

Enable IMAP

 - Open Gmail. Click Settings or ⚙️ in the top-right.
 - Click "See all settings". Navigate to "Forwarding and POP/IMAP".
 - Under "IMAP access", select "Enable IMAP" and save changes.

Generate an App Password

- If you have 2-Step Verification enabled, create an app password for "dc-mailer".
- Copy the 16-character password displayed.
- Paste the 16-char as your password in .env.toml file. Remove spaces.
- For detailed instructions, refer to [Google's support page](https://support.google.com/accounts/answer/185833?hl=en).

---

## Step 4. Import and Use in a Python Script

Once installed and your .env.toml file is ready, you can use it in your code. 

```python
from dc_mailer import send_mail

title = "Email from Data Analyst and Python Developer"
content = "Did you know the Python standard library enables emailing?"
recipient = "youremail@gmail.com"

try:
    send_mail(subject=title, body=content, recipient=recipient)
    print("SUCCESS: Email sent.")
except RuntimeError as e:
    print(f"ERROR: Sending failed: {e}")
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dc-mailer",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "email, alert, notification",
    "author": null,
    "author_email": "Denise Case <denisecase@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/31/e8/497edbbb1730e7705291f2d131e3d724dc6661fc464c884008c9550c0c59/dc_mailer-0.1.5.tar.gz",
    "platform": null,
    "description": "# dc-mailer\n\n> Send an email alert using Python and Gmail\n\n## Requirements\n\n- Python 3.11+ (required for reading toml files)\n- A configured Gmail Account (see below)\n\n---\n\n## Step 1. Install this Module\n\nRun\n\n```\npip install dc-mailer\n```\n\nOr: add `dc-mailer` to requirements.txt and install. \n\n---\n\n## Step 2. Configure Application Settings\n\n### Local Development\nFor local development, we can configure our settings with a file.\nFirst, add .env.toml to .gitignore to keep it from being published.\nThen, create a .env.toml file in your project directory with the following.\n```\noutgoing_email_host = \"smtp.gmail.com\"\noutgoing_email_port = 587\noutgoing_email_address = \"youremail@gmail.com\"\noutgoing_email_password = \"aaaabbbbccccdddd\"\n```\n\n### GitHub Action Deployments\nIn a deployment environment like GitHub Actions, the .env.toml file won't be available. Instead, you'll need to set the configuration variables as environment variables.\n\nFirst, add the following secrets to your GitHub repository:\n\n1. Navigate to your repository on GitHub.\n2. Click on Settings > Secrets and variables > Actions.\n3. Click on New repository secret and add the following secrets:\n    - OUTGOING_EMAIL_HOST: Set this to \"smtp.gmail.com\".\n    - OUTGOING_EMAIL_PORT: Set this to 587.\n    - OUTGOING_EMAIL_ADDRESS: Set this to your email address (e.g., \"your-email@gmail.com\").\n    - OUTGOING_EMAIL_PASSWORD: Set this to your application password.\n\nNext, reference these secrets in your GitHub Actions workflow. \nFor an example, see [this deploy.yml](https://github.com/denisecase/kafka-producer-earthquake/blob/main/.github/workflows/deploy.yml).\n\n---\n\n## Step 3. Configure Gmail \n\nEnable IMAP\n\n - Open Gmail. Click Settings or \u2699\ufe0f in the top-right.\n - Click \"See all settings\". Navigate to \"Forwarding and POP/IMAP\".\n - Under \"IMAP access\", select \"Enable IMAP\" and save changes.\n\nGenerate an App Password\n\n- If you have 2-Step Verification enabled, create an app password for \"dc-mailer\".\n- Copy the 16-character password displayed.\n- Paste the 16-char as your password in .env.toml file. Remove spaces.\n- For detailed instructions, refer to [Google's support page](https://support.google.com/accounts/answer/185833?hl=en).\n\n---\n\n## Step 4. Import and Use in a Python Script\n\nOnce installed and your .env.toml file is ready, you can use it in your code. \n\n```python\nfrom dc_mailer import send_mail\n\ntitle = \"Email from Data Analyst and Python Developer\"\ncontent = \"Did you know the Python standard library enables emailing?\"\nrecipient = \"youremail@gmail.com\"\n\ntry:\n    send_mail(subject=title, body=content, recipient=recipient)\n    print(\"SUCCESS: Email sent.\")\nexcept RuntimeError as e:\n    print(f\"ERROR: Sending failed: {e}\")\n```\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2025 Denise Case\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.\n        ",
    "summary": "A simple email alert utility for Python projects",
    "version": "0.1.5",
    "project_urls": {
        "BugTracker": "https://github.com/denisecase/dc-mailer/issues",
        "Homepage": "https://github.com/denisecase/dc-mailer",
        "Repository": "https://github.com/denisecase/dc-mailer"
    },
    "split_keywords": [
        "email",
        " alert",
        " notification"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "67f6a679cf00baca688452a1dfbf4043894022b7ccd4f80bb2e909552713844c",
                "md5": "7f12a8f97c9aed17af4e24e5945f8729",
                "sha256": "a0de6e2abeb2bdd9a5715f23cf8d8522286b9062c5642a5d2c8fc14dc492909e"
            },
            "downloads": -1,
            "filename": "dc_mailer-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7f12a8f97c9aed17af4e24e5945f8729",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 7294,
            "upload_time": "2025-02-04T04:23:20",
            "upload_time_iso_8601": "2025-02-04T04:23:20.452602Z",
            "url": "https://files.pythonhosted.org/packages/67/f6/a679cf00baca688452a1dfbf4043894022b7ccd4f80bb2e909552713844c/dc_mailer-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "31e8497edbbb1730e7705291f2d131e3d724dc6661fc464c884008c9550c0c59",
                "md5": "7a3e6895e9671f8af813ea8f0cdbc985",
                "sha256": "0f1ef2e399522356af5115fb5e6c020dbf06b01c70cb61ec95459b1fba8c3391"
            },
            "downloads": -1,
            "filename": "dc_mailer-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "7a3e6895e9671f8af813ea8f0cdbc985",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 7977,
            "upload_time": "2025-02-04T04:23:22",
            "upload_time_iso_8601": "2025-02-04T04:23:22.168748Z",
            "url": "https://files.pythonhosted.org/packages/31/e8/497edbbb1730e7705291f2d131e3d724dc6661fc464c884008c9550c0c59/dc_mailer-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-04 04:23:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "denisecase",
    "github_project": "dc-mailer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pip",
            "specs": []
        },
        {
            "name": "setuptools",
            "specs": []
        },
        {
            "name": "wheel",
            "specs": []
        },
        {
            "name": "build",
            "specs": []
        },
        {
            "name": "twine",
            "specs": []
        },
        {
            "name": "pytest",
            "specs": []
        }
    ],
    "lcname": "dc-mailer"
}
        
Elapsed time: 0.40685s