Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
geozeke committed Jan 15, 2025
0 parents commit 8622902
Show file tree
Hide file tree
Showing 12 changed files with 1,114 additions and 0 deletions.
158 changes: 158 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
.python-version
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos
# into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since
# the code is intended to run in multiple environments; otherwise,
# check them in:
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include
# Pipfile.lock in version control. However, in case of collaboration,
# if having platform-specific dependencies or dependencies having no
# cross-platform support, pipenv may install dependencies that don't
# work, or not install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv/
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# ruff
.ruff_cache/

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintainted in a separate
# JetBrains.gitignore that can be found at
# https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file.
# For a more nuclear option (not recommended) you can uncomment the
# following to ignore the entire idea folder.
#.idea/

# Custom exclusions
scratch/
.init/
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog

<!--------------------------------------------------------------------->

## [0.1.2][0.1.2] - 2025-01-15

_Beta Release._

[0.1.2]: https://github.com/geozeke/smvp/releases/tag/v0.1.2
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright 2025 Peter Nardi

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 NON-INFRINGEMENT.
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.
97 changes: 97 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
all: help

# --------------------------------------------

.PHONY: setup
setup: ## setup project with runtime dependencies
ifeq (,$(wildcard .init/setup))
@(which uv > /dev/null 2>&1) || \
(echo "smvp requires uv. See README for instructions."; exit 1)
@if [ ! -d "./scratch" ]; then \
mkdir -p scratch; \
fi
mkdir .init
touch .init/setup
uv sync --no-dev --frozen
else
@echo "Initial setup is already complete. If you are having issues, run:"
@echo
@echo "make reset"
@echo "make setup"
@echo
endif

# --------------------------------------------

.PHONY: dev
dev: ## add development dependencies (run make setup first)
ifneq (,$(wildcard .init/setup))
uv sync --frozen
@touch .init/dev
else
@echo "Please run \"make setup\" first"
endif

# --------------------------------------------

.PHONY: upgrade
upgrade: ## upgrade project dependencies
ifeq (,$(wildcard .init/dev))
uv sync --no-dev --upgrade
else
uv sync --upgrade
endif

# --------------------------------------------

.PHONY: reset
reset: clean ## remove venv, artifacts, and init directory
@echo Resetting project state
rm -rf .init .ruff_cache .mypy_cache .venv

# --------------------------------------------

.PHONY: build
build: ## build package for publishing
rm -rf dist
uv build

# --------------------------------------------

.PHONY: publish-production
publish-production: build ## publish package to pypi.org for production
uv publish --publish-url https://upload.pypi.org/legacy/ \
--token ${PYPITOKEN}

# --------------------------------------------

.PHONY: publish-test
publish-test: build ## publish package to test.pypi.org for testing
uv publish --publish-url https://test.pypi.org/legacy/ \
--token ${TESTPYPITOKEN}

# --------------------------------------------

.PHONY: clean
clean: ## cleanup python runtime and build artifacts
@echo Cleaning python runtime and build artifacts
@rm -rf build/
@rm -rf dist/
@find . -type d -name __pycache__ -exec rm -rf {} \; -prune
@find . -type d -name .pytest_cache -exec rm -rf {} \; -prune
@find . -type d -name .eggs -exec rm -rf {} \; -prune
@find . -type d -name htmlcov -exec rm -rf {} \; -prune
@find . -type d -name *.egg-info -exec rm -rf {} \; -prune
@find . -type f -name *.egg -delete
@find . -type f -name *.pyc -delete
@find . -type f -name *.pyo -delete
@find . -type f -name *.coverage -delete

# --------------------------------------------

.PHONY: help
help: ## show help
@echo Please specify a target. Choices are:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk \
'BEGIN {FS = ":.*?## "}; \
{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
88 changes: 88 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Send Mail Via Python (smvp)

<br>

<img src="https://lh3.googleusercontent.com/d/1PpjTCw4T1HpHU_TacQSjZptzw67WqwIz"
alt="smvp logo" width="120"/>

The _smvp_ utility takes a file whose contents will be parsed and packaged
into the body of an email message, then sent to a designated email
address. The input file can be a text file with ANSI color codes, HTML,
or plain text. The resulting email will be sent as a multi-part MIME
message that renders properly in both plain text and HTML.

_Note: The file itself is not sent as an attachment; instead, the
contents of the file are put into into the body of the email._

## Use Case

There are probably many, but I wrote _smvp_ so my cron scripts can email
me status information and the contents of log files. Some of the files
contain ANSI escape sequences for terminal colors. The _smvp_ utility
converts those ANSI escape sequences into proper HTML tags, so the
emails I get are nicely formatted.

## Installation

Use your preferred python package installer for command line tools, for
example:

```text
pipx install smvp
```

or

```text
uv tool install smvp
```

## Requirements

### First

Make sure the following environment variables are set and exported in
your current shell:

```text
export SMVP_USER="<your email>" # e.g. "[email protected]"
export SMVP_TOKEN="<your token>" # e.g. "<gmail app password>"
export SMVP_SERVER="<smtp server>" # e.g. "smtp.gmail.com"
```

It is recommended that you put the lines above in your "rc" file
(`.bashrc`, `.zshrc`, etc.) for use across multiple shell sessions and
processes. To confirm you have the environment variables correctly set
(with the correct spellings), run this in a terminal:

```text
set | grep ^SMVP_
```

_Note: If you make changes to your "rc" file, make sure to "source" it
or open a new terminal window before running smvp again._

### Second

The `SMVP_SERVER` you select must support secure TLS connections on
port `587`. Check the SMTP settings for your email provider. This is the
default TLS port on Gmail, so if you're using your Gmail account to send
emails, you're good-to-go.

## Usage

```text
usage: smvp [-h] recipient subject file
```

For example:

```text
smvp [email protected] "Hello, Friend" ~/logfile.txt
```

For more details, run:

```text
smvp -h
```
Loading

0 comments on commit 8622902

Please sign in to comment.