Skip to content

Commit

Permalink
v1.2.0 closes #149 #147 #146 #151 #150 (#152)
Browse files Browse the repository at this point in the history
* v1.1.6 closes #149 #147 #146

* v1.1.6 fix group dependecies

* Fully updated repo

* fix linter issues
  • Loading branch information
sabuhish authored Oct 11, 2022
1 parent 54f396b commit 2faf971
Show file tree
Hide file tree
Showing 25 changed files with 693 additions and 513 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI
on:
push:
branches: '**'

jobs:
ci:
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
poetry-version: [1.1.8]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Run image
uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Install dependencies
run: poetry install
- name: Run Linter
run: poetry run make
104 changes: 48 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,32 @@ The fastapi-mail simple lightweight mail system, sending emails and attachments(

### 🔨 Installation ###

```sh
$ pip install fastapi-mail

```bash
python3 -m venv .venv

source .venv/bin/activate

pip install fastapi-mail

for aioredis and httpx

pip install 'fastapi-mail[aioredis]'
pip install 'fastapi-mail[httpx]'

```

Alternatively, if you prefer to use `poetry` for package dependencies:

```bash
poetry shell

python add fastapi-mail

for aioredis and httpx

python add 'fastapi-mail[aioredis]'
python add 'fastapi-mail[httpx]'
```

---
Expand All @@ -40,27 +64,27 @@ More information on [Getting-Started](https://sabuhish.github.io/fastapi-mail/ge

```python

from fastapi import FastAPI, BackgroundTasks, UploadFile, File, Form
from starlette.responses import JSONResponse
from starlette.requests import Request
from fastapi_mail import FastMail, MessageSchema,ConnectionConfig
from pydantic import BaseModel, EmailStr
from typing import List

from fastapi import BackgroundTasks, FastAPI
from fastapi_mail import ConnectionConfig, FastMail, MessageSchema, MessageType
from pydantic import BaseModel, EmailStr
from starlette.responses import JSONResponse



class EmailSchema(BaseModel):
email: List[EmailStr]


conf = ConnectionConfig(
MAIL_USERNAME = "YourUsername",
MAIL_PASSWORD = "strong_password",
MAIL_FROM = "your@email.com",
MAIL_PORT = 587,
MAIL_SERVER = "your mail server",
MAIL_TLS = True,
MAIL_SSL = False,
MAIL_USERNAME ="username",
MAIL_PASSWORD = "**********",
MAIL_FROM = "test@email.com",
MAIL_PORT = 465,
MAIL_SERVER = "mail server",
MAIL_STARTTLS = False,
MAIL_SSL_TLS = True,
USE_CREDENTIALS = True,
VALIDATE_CERTS = True
)
Expand All @@ -78,10 +102,9 @@ async def simple_send(email: EmailSchema) -> JSONResponse:

message = MessageSchema(
subject="Fastapi-Mail module",
recipients=email.dict().get("email"), # List of recipients, as many as you can pass
recipients=email.dict().get("email"),
body=html,
subtype="html"
)
subtype=MessageType.html)

fm = FastMail(conf)
await fm.send_message(message)
Expand All @@ -90,51 +113,20 @@ async def simple_send(email: EmailSchema) -> JSONResponse:

## List of Examples

For more examples of using fastapi-mail please check [example](https://sabuhish.github.io/fastapi-mail/example/) section

# Contributing
Feel free to open issues and send pull requests.
For more examples of using fastapi-mail please check:
[example](https://sabuhish.github.io/fastapi-mail/example/) section.


## Contributors ✨

Thanks goes to these wonderful people ([🚧](https://sabuhish.github.io/fastapi-mail/example.html)):


<table>
<tr>
<td align="center"><a href="https://github.com/sabuhish"><img src="https://avatars.githubusercontent.com/u/46589585?v=3" width="100px;" alt=""/><br /><sub><b>Sabuhi Shukurov</b></sub></a><br /><a href="#maintenance-tbenning" title="Answering Questions">💬</a> <a href="https://github.com/sabuhish/fastapi-mail/" title="Reviewed Pull Requests">👀</a> <a href="#maintenance-jakebolam" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/Turall"><img src="https://avatars.githubusercontent.com/u/32899328?v=3" width="100px;" alt=""/><br /><sub><b>Tural Muradov</b></sub></a><br /><a href="https://github.com/sabuhish/fastapi-mail/" title="Documentation">📖</a> <a href="https://github.com/sabuhish/fastapi-mail/" title="Reviewed Pull Requests">👀</a> <a href="#tool-jfmengels" title="Tools">🔧</a></td>
<td align="center"><a href="https://github.com/AliyevH"><img src="https://avatars.githubusercontent.com/u/5507950?v=3" width="100px;" alt=""/><br /><sub><b>Hasan Aliyev</b></sub></a><br /><a href="https://github.com/sabuhish/fastapi-mail/" title="Documentation">📖</a> <a href="#maintenance-jakebolam" title="Maintenance">🚧</a> <a href="https://github.com/sabuhish/fastapi-mail/" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://github.com/imaskm"><img src="https://avatars.githubusercontent.com/u/20543833?v=3" width="100px;" alt=""/><br /><sub><b>Ashwani</b></sub></a><br /><a href="#maintenance-tbenning" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/LLYX"><img src="https://avatars1.githubusercontent.com/u/10430633" width="100px;" alt=""/><br /><sub><b>Leon Xu</b></sub></a><br /><a href="#maintenance-tbenning" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/gabrielponto"><img src="https://avatars.githubusercontent.com/u/7227328" width="100px;" alt=""/><br /><sub><b>Gabriel Oliveira</b></sub></a><br /><a href="https://github.com/sabuhish/fastapi-mail/" title="Documentation">📖</a> <a href="#maintenance-jakebolam" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/maestro-1"><img src="https://avatars0.githubusercontent.com/u/40833254" width="100px;" alt=""/><br /><sub><b>Onothoja Marho</b></sub></a><br /><a href="https://github.com/sabuhish/fastapi-mail/" title="Documentation">📖</a> <a href="#maintenance-jakebolam" title="Maintenance">🚧</a> <a href="#tool-jfmengels" title="Tools">🔧</a></td>

</tr>
<tr>
<td align="center"><a href="https://github.com/TheTimKiely"><img src="https://avatars1.githubusercontent.com/u/34795732" width="100px;" alt=""/><br /><sub><b>Tim Kiely</b></sub></a><br /><a href="#maintenance-tbenning" title="Maintenance">🚧</a></td>
<td align="center"><a href=https://github.com/DmitriySolodkiy"><img src="https://avatars1.githubusercontent.com/u/37667152" width="100px;" alt=""/><br/><sub><b>Dmitriy Solodkiy</b></sub></a><br /><a href="#maintenance-tbenning" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/pboers1988"><img src="https://avatars1.githubusercontent.com/u/3235585" width="100px;" alt=""/><br /><sub><b>Peter Boers</b></sub></a><br /><a href="#maintenance-tbenning" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/jdvalentine"><img src="https://avatars.githubusercontent.com/u/557514" width="100px;" alt=""/><br /><sub><b>James Valentine</b></sub></a><br /><a href="https://github.com/sabuhish/fastapi-mail/" title="Documentation">📖</a> <a href="#maintenance-jakebolam" title="Maintenance">🚧</a> <a href="#tool-jfmengels" title="Tools">🔧</a></td>
<td align="center"><a href="https://github.com/gogoku"><img src="https://avatars.githubusercontent.com/u/25707104" width="100px;" alt=""/><br /><sub><b>Gogoku</b></sub></a><br /><a href="https://github.com/sabuhish/fastapi-mail/" title="Documentation">📖</a> <a href="#maintenance-jakebolam" title="Maintenance">🚧</a> <a href="#tool-jfmengels" title="Tools">🔧</a></td>
<td align="center"><a href="https://github.com/kucera-lukas"><img src="https://avatars.githubusercontent.com/u/85391931" width="100px;" alt=""/><br /><sub><b>Kucera-Lukas</b></sub></a><br /><a href="https://github.com/sabuhish/fastapi-mail/" title="Documentation">📖</a> <a href="#maintenance-jakebolam" title="Maintenance">🚧</a> <a href="#tool-jfmengels" title="Tools">🔧</a></td>
<td align="center"><a href="https://github.com/LLYX"><img src="https://avatars.githubusercontent.com/u/10430633" width="100px;" alt=""/><br /><sub><b>LLYX</b></sub></a><br /><a href="https://github.com/sabuhish/fastapi-mail/" title="Documentation">📖</a> <a href="#maintenance-jakebolam" title="Maintenance">🚧</a> <a href="#tool-jfmengels" title="Tools">🔧</a></td></tr>

<tr>
<td align="center"><a href="https://github.com/floodpants"><img src="https://avatars.githubusercontent.com/u/37890036?" width="100px;" alt=""/><br /><sub><b>floodpants</b></sub></a><br /><a href="#maintenance-tbenning" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/andredias"><img src="https://avatars.githubusercontent.com/u/902540" width="100px;" alt=""/><br /><sub><b>André Felipe Dias</b></sub></a><br /><a href="https://github.com/sabuhish/fastapi-mail/" title="Documentation">📖</a> <a href="https://github.com/sabuhish/fastapi-mail/" title="Reviewed Pull Requests">👀</a> <a href="#tool-jfmengels" title="Tools">🔧</a></td></b></sub></a><br /><a href="#maintenance-tbenning" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/wjurkowlaniec"><img src="https://avatars.githubusercontent.com/u/1134323" width="100px;" alt=""/><br /><sub><b>Wojtek Jurkowlaniec</b></sub></a><br /><a href="https://github.com/sabuhish/fastapi-mail/" title="Documentation">📖</a> <a href="https://github.com/sabuhish/fastapi-mail/" title="Reviewed Pull Requests">👀</a> <a href="#tool-jfmengels" title="Tools">🔧</a></td></b></sub></a><br /><a href="#maintenance-tbenning" title="Maintenance">🚧</a></td>

</tr>
</table>


This project follows the [all-contributors](https://allcontributors.org) specification.
Contributions of any kind are welcome!
Thanks goes to these wonderful
[People](https://sabuhish.github.io/fastapi-mail/contributors.txt)


Before you start please read [CONTRIBUTING](https://github.com/sabuhish/fastapi-mail/blob/master/CONTRIBUTING.md)
# Contributing
Contributions of any kind are welcome!

Before you start, please read [CONTRIBUTING](https://github.com/sabuhish/fastapi-mail/blob/master/CONTRIBUTING.md)


## LICENSE
Expand Down
33 changes: 28 additions & 5 deletions contributors.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
Sabuhi Shukurov <sabuhi.shukurov@gmail.com>
Tural Muradov <tural_m@hotmail.com>
Hasan Aliyev <hasan.aliyev.555@gmail.com>
Ashwani <ashwanisharma686@gmail.com>

Name | Surname | Github account
Tural Muradov https://github.com/Turall
Hasan Aliyev https://github.com/AliyevH
Onothoja Marho https://github.com/maestro-1
André Felipe Dias https://github.com/andredias
Dmitriy Solodkiy https://github.com/DmitriySolodkiy
Peter Boers https://github.com/pboers1988
Leon Xu https://github.com/LLYX
SASAO Takahiro https://github.com/tsasao
Lucas Balieiro https://github.com/lucasbalieiro
floodpants https://github.com/floodpants
Dusan Vuckovic https://github.com/dvuckovic
Mike Bamford https://github.com/msb
Siôn Abraham https://github.com/SionAbes
Jansen A. Simanullang https://github.com/jansenicus
Mariusz Masztalerczuk https://github.com/mmasztalerczuk
Ikko Ashimine https://github.com/eltociear
Wojtek Jurkowlaniec https://github.com/wjurkowlaniec
gogoku https://github.com/gogoku
Kristian Nymann Jakobsen https://github.com/nymann
trinqk https://github.com/trinqk
IsaiahT-Tech https://github.com/IsaiahT-Tech
Satwik Kansal https://github.com/satwikkansal
Tim Kiely https://github.com/TheTimKiely
Gabriel Oliveira https://github.com/gabrielponto
Ashwani https://github.com/imaskm
Lukas Kucera https://github.com/kucera-lukas

22 changes: 3 additions & 19 deletions docs/contribute.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Contributing to fastapi-mail
Contributing to fastapi-mail:
=========================================

We welcome contributions to [fastapi-mail](https://github.com/sabuhish/fastapi-mail)
We welcome contributions to [FastAPI-Mail](https://github.com/sabuhish/fastapi-mail)

Issues
------

Feel free to submit issues and enhancement requests.

[Fatapi-Mail Issues](https://github.com/sabuhish/fastapi-mail/issues)
[FastAPI-Mail issues](https://github.com/sabuhish/fastapi-mail/issues)

Contributing
------------
Expand All @@ -20,20 +20,4 @@ Please refer to each project's style and contribution guidelines for submitting
4. **Push** your work
5. Submit a **Pull request** so that we can review your changes


### Before Start


```sh
$ bash fastapi-mail.sh install
$ source .venv/bin/activate
$ cat app.py
```

```sh
uvicorn app:app --port 8000 --reload
```



NOTE: Be sure to merge the latest from `upstream` before making a pull request!
59 changes: 27 additions & 32 deletions docs/example.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@


## Sending email with FastApi
## Sending email with FastAPI-Mail

### List of Useful Examples
### Standart way of sending email with FastAPI
```python
from fastapi import FastAPI
from starlette.responses import JSONResponse
from fastapi_mail import FastMail, MessageSchema,ConnectionConfig
from fastapi_mail import FastMail, MessageSchema, ConnectionConfig, MessageType
from pydantic import EmailStr, BaseModel
from typing import List

Expand All @@ -15,37 +15,31 @@ class EmailSchema(BaseModel):


conf = ConnectionConfig(
MAIL_USERNAME = "YourUsername",
MAIL_PASSWORD = "strong_password",
MAIL_FROM = "your@email.com",
MAIL_USERNAME = "username",
MAIL_PASSWORD = "**********",
MAIL_FROM = "test@email.com",
MAIL_PORT = 587,
MAIL_SERVER = "your mail server",
MAIL_SERVER = "mail server",
MAIL_FROM_NAME="Desired Name",
MAIL_TLS = True,
MAIL_SSL = False,
MAIL_STARTTLS = True,
MAIL_SSL_TLS = False,
USE_CREDENTIALS = True,
VALIDATE_CERTS = True
)

app = FastAPI()


html = """
<p>Hi this test mail, thanks for using Fastapi-mail</p>
"""


@app.post("/email")
async def simple_send(
email: EmailSchema
) -> JSONResponse:
async def simple_send(email: EmailSchema) -> JSONResponse:
html = """<p>Hi this test mail, thanks for using Fastapi-mail</p> """

message = MessageSchema(
subject="Fastapi-Mail module",
recipients=email.dict().get("email"), # List of recipients, as many as you can pass
recipients=email.dict().get("email"),
body=html,
subtype="html"
)
subtype=MessageType.html)

fm = FastMail(conf)
await fm.send_message(message)
Expand All @@ -66,7 +60,7 @@ async def send_in_background(
subject="Fastapi mail module",
recipients=email.dict().get("email"),
body="Simple background task",
)
subtype=MessageType.plain)

fm = FastMail(conf)

Expand All @@ -90,9 +84,9 @@ async def send_file(
message = MessageSchema(
subject="Fastapi mail module",
recipients=[email],
body="Simple background task ",
attachments=[file]
)
body="Simple background task",
subtype=MessageType.html,
attachments=[file])

fm = FastMail(conf)

Expand Down Expand Up @@ -120,8 +114,8 @@ conf = ConnectionConfig(
MAIL_FROM = "your@email.com",
MAIL_PORT = 587,
MAIL_SERVER = "your mail server",
MAIL_TLS = True,
MAIL_SSL = False,
MAIL_STARTTLS = True,
MAIL_SSL_TLS = False,
TEMPLATE_FOLDER = Path(__file__).parent / 'templates',
)

Expand All @@ -131,8 +125,9 @@ async def send_with_template(email: EmailSchema) -> JSONResponse:

message = MessageSchema(
subject="Fastapi-Mail module",
recipients=email.dict().get("email"), # List of recipients, as many as you can pass
recipients=email.dict().get("email"),
template_body=email.dict().get("body"),
subtype=MessageType.html,
)

fm = FastMail(conf)
Expand Down Expand Up @@ -183,8 +178,8 @@ Used for example for referencing Content-ID images in html of email
message = MessageSchema(
subject='Fastapi-Mail module',
recipients=recipients,
html="<img src='cid:logo_image@fastapi-mail'>",
subtype='html',
body="<img src='cid:logo_image@fastapi-mail'>",
subtype=MessageType.html,
attachments=[
{
"file": "/path/to/file.png",
Expand Down Expand Up @@ -410,8 +405,8 @@ conf = ConnectionConfig(
MAIL_FROM = "your@email.com",
MAIL_PORT = 587,
MAIL_SERVER = "your mail server",
MAIL_TLS = True,
MAIL_SSL = False,
MAIL_STARTTLS = True,
MAIL_SSL_TLS = False,
TEMPLATE_FOLDER = Path(__file__).parent / 'templates',

# if no indicated SUPPRESS_SEND defaults to 0 (false) as below
Expand All @@ -425,9 +420,9 @@ async def simple_send(email: EmailSchema) -> JSONResponse:

message = MessageSchema(
subject="Testing",
recipients=email.dict().get("email"), # List of recipients, as many as you can pass
recipients=email.dict().get("email"),
body=html,
subtype="html"
subtype=MessageType.html,
)

await fm.send_message(message)
Expand Down
Loading

0 comments on commit 2faf971

Please # to comment.