Name | mymailsender JSON |
Version |
0.1.6
JSON |
| download |
home_page | None |
Summary | A simple Python mailer for SMTP sending. |
upload_time | 2024-12-27 18:13:22 |
maintainer | None |
docs_url | None |
author | None |
requires_python | None |
license | MIT |
keywords |
smtp
email
mailer
|
VCS |
|
bugtrack_url |
|
requirements |
PyYAML
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[![PyPI version](https://badge.fury.io/py/mymailsender.svg)](https://badge.fury.io/py/mymailsender)
[![Build Status](https://github.com/mariusei/mymailsender/actions/workflows/python-publish.yml/badge.svg)](https://github.com/mariusei/mymailsender/actions/workflows/python-publish.yml)
# MyMailSender
A simple Python wrapper for sending SMTP emails. This package lets you configure:
- **TLS/SSL** or **plain** connections
- **Authentication** or unauthenticated connections
- **Attachments**, HTML/Plain text messages, CC and BCC
- And more...
## Table of Contents
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Configuration](#configuration)
- [Usage Examples](#usage-examples)
- [Send a Basic Email](#send-a-basic-email)
- [Send an Email with Attachments](#send-an-email-with-attachments)
- [Using CC and BCC](#using-cc-and-bcc)
- [License](#license)
---
## Installation
1. **Clone** or **download** this repository.
2. Navigate to the project directory (where `pyproject.toml` or `setup.py` is located).
3. Install in editable/development mode:
```bash
pip install -e .
```
Alternatively, if you've built a wheel or `tar.gz`:
```bash
pip install dist/mymailsender-0.1.0-py3-none-any.whl
```
Once installed, you can import it anywhere in your code:
```python
from mymailsender import MyMailSender
```
---
## Quick Start
```python
from mymailsender import MyMailSender
# Example instantiation of the MyMailSender class
mymailsender = MyMailSender(
smtp_server="smtp.example.com",
port=25, # or 587 for TLS, 465 for SSL, etc.
use_tls=False, # True if you want STARTTLS
use_ssl=False, # True if using SSL on port 465
use_auth=False, # True if the server requires username/password
)
# Send a simple email
mymailsender.send_mail(
sender_email="me@example.com",
recipient_emails=["you@example.org"],
subject="Hello World",
body_text="This is a test email using mymailsender."
)
```
---
## Configuration
The `MyMailSender` class uses a `mailsender.yaml` file for default configurations. This file should be placed in the project directory and can include the following settings:
```yaml
smtp_server: "smtp.example.com"
port: 25
use_tls: false
use_ssl: false
use_auth: false
username: "your_username"
password: "your_password"
```
You can also override these settings by providing arguments when initializing the `MyMailSender` instance:
```python
from mymailsender import MyMailSender
mymailsender = MyMailSender(
smtp_server="smtp.override.com",
port=587,
use_tls=True,
# Additional overrides as needed
)
```
The available configuration parameters are:
- **smtp_server** (str): The domain or IP of your SMTP server, e.g. `"smtp.gmail.com"`, `"localhost"`, etc.
- **port** (int): The SMTP port. Often `25` or `587` (if `use_tls=True`), or `465` (if `use_ssl=True`).
- **use_tls** (bool): Set to `True` to enable STARTTLS after connecting. Typically used with port 587.
- **use_ssl** (bool): Set to `True` if you want an SSL connection from the start (SMTPS). Typically used with port 465.
- **use_auth** (bool): Set to `True` if the server requires authentication with username and password.
- **username** (str, optional): Your SMTP username (if `use_auth=True`).
- **password** (str, optional): Your SMTP password (if `use_auth=True`).
---
## Usage Examples
### Send a Basic Email
```python
from mymailsender import MyMailSender
# Create the MyMailSender
mymail = MyMailSender(
smtp_server="localhost",
port=25,
use_tls=False,
use_ssl=False,
use_auth=False
)
# Send a basic text-only message
mymail.send_mail(
sender_email="sender@localhost",
recipient_emails=["recipient@localhost"],
subject="Test Email",
body_text="Hello from mymailsender!",
)
```
### Send an Email with Attachments
```python
from mymailsender import MyMailSender
mymail = MyMailSender(
smtp_server="smtp.example.com",
port=587,
use_tls=True,
use_ssl=False,
use_auth=True,
username="myuser",
password="mypassword"
)
mymail.send_mail(
sender_email="myuser@example.com",
recipient_emails=["recipient@example.org"],
subject="Hello with Attachments",
body_text="Hello, please see the attached files.",
attachments=[
"reports/report1.pdf",
"/path/to/image.png"
]
)
```
### Using CC and BCC
Configure some custom connection settings in `mailsender.yaml`:
```yaml
smtp_server: "smtp.example.com"
username: myusername
password: mypass
```
Which now allows you to initialize the `MyMailSender` instance without specifying any arguments:
```python
from mymailsender import MyMailSender
mymail = MyMailSender()
mymail.send_mail(
sender_email="me@example.com",
recipient_emails=["primary@example.org"],
subject="Test CC and BCC",
body_text="Hello, just testing CC and BCC!",
cc_emails=["colleague@example.org"],
bcc_emails=["secret@example.org"]
)
```
---
## License
This project is distributed under the [MIT License](LICENSE). Feel free to use it, modify it, or distribute it as you wish. See [LICENSE](LICENSE) for more information.
Raw data
{
"_id": null,
"home_page": null,
"name": "mymailsender",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "smtp, email, mailer",
"author": null,
"author_email": "Marius Berge Eide <mariusbe@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/dd/f5/9ce199c336add9b22b60cd7d2f8ab9ec3a7eda8fc61f8cf51fa20d6ac1c3/mymailsender-0.1.6.tar.gz",
"platform": null,
"description": "[![PyPI version](https://badge.fury.io/py/mymailsender.svg)](https://badge.fury.io/py/mymailsender)\n[![Build Status](https://github.com/mariusei/mymailsender/actions/workflows/python-publish.yml/badge.svg)](https://github.com/mariusei/mymailsender/actions/workflows/python-publish.yml)\n\n# MyMailSender\n\nA simple Python wrapper for sending SMTP emails. This package lets you configure:\n- **TLS/SSL** or **plain** connections\n- **Authentication** or unauthenticated connections\n- **Attachments**, HTML/Plain text messages, CC and BCC\n- And more...\n\n## Table of Contents\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Configuration](#configuration)\n- [Usage Examples](#usage-examples)\n - [Send a Basic Email](#send-a-basic-email)\n - [Send an Email with Attachments](#send-an-email-with-attachments)\n - [Using CC and BCC](#using-cc-and-bcc)\n- [License](#license)\n\n---\n\n## Installation\n\n1. **Clone** or **download** this repository.\n2. Navigate to the project directory (where `pyproject.toml` or `setup.py` is located).\n3. Install in editable/development mode:\n\n ```bash\n pip install -e .\n ```\n\n Alternatively, if you've built a wheel or `tar.gz`:\n\n ```bash\n pip install dist/mymailsender-0.1.0-py3-none-any.whl\n ```\n\nOnce installed, you can import it anywhere in your code:\n\n```python\nfrom mymailsender import MyMailSender\n```\n\n---\n\n## Quick Start\n\n```python\nfrom mymailsender import MyMailSender\n\n# Example instantiation of the MyMailSender class\nmymailsender = MyMailSender(\n smtp_server=\"smtp.example.com\",\n port=25, # or 587 for TLS, 465 for SSL, etc.\n use_tls=False, # True if you want STARTTLS\n use_ssl=False, # True if using SSL on port 465\n use_auth=False, # True if the server requires username/password\n)\n\n# Send a simple email\nmymailsender.send_mail(\n sender_email=\"me@example.com\",\n recipient_emails=[\"you@example.org\"],\n subject=\"Hello World\",\n body_text=\"This is a test email using mymailsender.\"\n)\n```\n\n---\n\n## Configuration\n\nThe `MyMailSender` class uses a `mailsender.yaml` file for default configurations. This file should be placed in the project directory and can include the following settings:\n\n```yaml\nsmtp_server: \"smtp.example.com\"\nport: 25\nuse_tls: false\nuse_ssl: false\nuse_auth: false\nusername: \"your_username\"\npassword: \"your_password\"\n```\n\nYou can also override these settings by providing arguments when initializing the `MyMailSender` instance:\n\n```python\nfrom mymailsender import MyMailSender\n\nmymailsender = MyMailSender(\n smtp_server=\"smtp.override.com\",\n port=587,\n use_tls=True,\n # Additional overrides as needed\n)\n```\n\nThe available configuration parameters are:\n\n- **smtp_server** (str): The domain or IP of your SMTP server, e.g. `\"smtp.gmail.com\"`, `\"localhost\"`, etc.\n- **port** (int): The SMTP port. Often `25` or `587` (if `use_tls=True`), or `465` (if `use_ssl=True`).\n- **use_tls** (bool): Set to `True` to enable STARTTLS after connecting. Typically used with port 587.\n- **use_ssl** (bool): Set to `True` if you want an SSL connection from the start (SMTPS). Typically used with port 465.\n- **use_auth** (bool): Set to `True` if the server requires authentication with username and password.\n- **username** (str, optional): Your SMTP username (if `use_auth=True`).\n- **password** (str, optional): Your SMTP password (if `use_auth=True`).\n\n---\n\n## Usage Examples\n\n### Send a Basic Email\n\n```python\nfrom mymailsender import MyMailSender\n\n# Create the MyMailSender\nmymail = MyMailSender(\n smtp_server=\"localhost\",\n port=25,\n use_tls=False,\n use_ssl=False,\n use_auth=False\n)\n\n# Send a basic text-only message\nmymail.send_mail(\n sender_email=\"sender@localhost\",\n recipient_emails=[\"recipient@localhost\"],\n subject=\"Test Email\",\n body_text=\"Hello from mymailsender!\",\n)\n```\n\n### Send an Email with Attachments\n\n```python\nfrom mymailsender import MyMailSender\n\nmymail = MyMailSender(\n smtp_server=\"smtp.example.com\",\n port=587,\n use_tls=True,\n use_ssl=False,\n use_auth=True,\n username=\"myuser\",\n password=\"mypassword\"\n)\n\nmymail.send_mail(\n sender_email=\"myuser@example.com\",\n recipient_emails=[\"recipient@example.org\"],\n subject=\"Hello with Attachments\",\n body_text=\"Hello, please see the attached files.\",\n attachments=[\n \"reports/report1.pdf\",\n \"/path/to/image.png\"\n ]\n)\n```\n\n### Using CC and BCC\n\nConfigure some custom connection settings in `mailsender.yaml`:\n\n```yaml\nsmtp_server: \"smtp.example.com\"\nusername: myusername\npassword: mypass\n```\n\nWhich now allows you to initialize the `MyMailSender` instance without specifying any arguments:\n\n```python\nfrom mymailsender import MyMailSender\n\nmymail = MyMailSender()\n\nmymail.send_mail(\n sender_email=\"me@example.com\",\n recipient_emails=[\"primary@example.org\"],\n subject=\"Test CC and BCC\",\n body_text=\"Hello, just testing CC and BCC!\",\n cc_emails=[\"colleague@example.org\"],\n bcc_emails=[\"secret@example.org\"]\n)\n```\n\n---\n\n## License\n\nThis project is distributed under the [MIT License](LICENSE). Feel free to use it, modify it, or distribute it as you wish. See [LICENSE](LICENSE) for more information.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A simple Python mailer for SMTP sending.",
"version": "0.1.6",
"project_urls": {
"Source Code": "https://github.com/mariusei/mymailsender"
},
"split_keywords": [
"smtp",
" email",
" mailer"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a9403e9c97c40dafd95e87159a9411c80ac5507e4aeaf44eae294d6720d4389b",
"md5": "dd80932b2051215a85773c8001f55407",
"sha256": "9d863d832ca1b6119f007fe339460f4aaaa46ee779e86f138db4ae821a7d69d9"
},
"downloads": -1,
"filename": "mymailsender-0.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dd80932b2051215a85773c8001f55407",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5873,
"upload_time": "2024-12-27T18:13:19",
"upload_time_iso_8601": "2024-12-27T18:13:19.849101Z",
"url": "https://files.pythonhosted.org/packages/a9/40/3e9c97c40dafd95e87159a9411c80ac5507e4aeaf44eae294d6720d4389b/mymailsender-0.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ddf59ce199c336add9b22b60cd7d2f8ab9ec3a7eda8fc61f8cf51fa20d6ac1c3",
"md5": "22f07863cea4d9e82ec04ad270ebc243",
"sha256": "70af6358405f6bdb14988249ce5c4d471376e424741fe6eaae48ea8bf9da4b58"
},
"downloads": -1,
"filename": "mymailsender-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "22f07863cea4d9e82ec04ad270ebc243",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5640,
"upload_time": "2024-12-27T18:13:22",
"upload_time_iso_8601": "2024-12-27T18:13:22.405178Z",
"url": "https://files.pythonhosted.org/packages/dd/f5/9ce199c336add9b22b60cd7d2f8ab9ec3a7eda8fc61f8cf51fa20d6ac1c3/mymailsender-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-27 18:13:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mariusei",
"github_project": "mymailsender",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "PyYAML",
"specs": [
[
"==",
"6.0.2"
]
]
}
],
"lcname": "mymailsender"
}