https://github.com/xinlin-z/littlemail
Command-line SMTP email sending tool in pure Python
https://github.com/xinlin-z/littlemail
command-line-tool email email-sender python3 smtp
Last synced: 4 months ago
JSON representation
Command-line SMTP email sending tool in pure Python
- Host: GitHub
- URL: https://github.com/xinlin-z/littlemail
- Owner: xinlin-z
- License: other
- Created: 2020-02-21T07:33:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-11-08T07:20:43.000Z (over 1 year ago)
- Last Synced: 2025-01-23T05:51:05.687Z (4 months ago)
- Topics: command-line-tool, email, email-sender, python3, smtp
- Language: Python
- Homepage:
- Size: 42 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/xinlin-z/littlemail/actions/workflows/master_update.yml)
# littlemail
* [Installation](#Installation)
* [Usage](#Usage)
* [API](#API)Littlemail is a straight-forward command-line SMTP email sending tool
in Python, which sends **one email per command**. (If you send many
emails, every sending will make a new connection with the smtp server.)## Installation
```shell
$ pip install littlemail
```## Usage
There is no way to reduce parameters provided in command-line, since
that's the way of email. So, please refer to the inline help for options
you need. Fortunately, many options have default value.``` shell
$ python -m littlemail -h # inline help
```Anyway, here is a minimal example and a few lines of explanation:
```shell
$ python -m littlemail -s test [-c hello] \
-f [email protected] \
--to [email protected] \
--smtp smtp.qq.com [-p abcdefg]
````-c` means the email content, which is optional. That means you can
send empty-content email. And this optional parameter enables the
capability of littlemail to get content from pipe (input
redirection), which might be easier for you to construct your message,
such as:```shell
$ python -m littlemail <...> < my_email_content.txt
````-s` represents subject, which is mandatory and cannot be empty.
`-p` stands for password, and it is optional. When it's missing,
littlemail tries to get password from `LITTLEMAIL_PASSWD`
environment variable.When something goes wrong, try `--debug`.
## API
There is an API you can invoke to send email in your code:
```python
# import
from littlemail import send_email
# signature
def send_email(subject: str,
*,
text: str = '',
contype: str = 'plain',
alist: list[str] = [],
to: list[str],
cc: list[str] = [],
bcc: list[str] = [],
fromaddr: str,
smtp: str,
port: int = 587,
timeout: int = 3,
protocol: str = 'tls',
passwd: str|None,
debug: bool = False) -> None: ...
````api_test.py` is used as an example and testcase for you to try,
have fun! ^___^