-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09f9390
commit e007eb0
Showing
19 changed files
with
172 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"git.ignoreLimitWarning": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
recursive-exclude flask-mailing/examples * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
# Flask-Mailing | ||
![Flask mail logo](https://github.com/marktennyson/flask-mailing/blob/main/flask-mailing-logo-cropped.png?raw=true) | ||
|
||
Flask-Mailing adds SMTP mail sending to your Flask applications | ||
|
||
Flask_Mail is dead now. To use the mail service with your project you can use eaither [Flask-Mailing](https://github.com/marktennyson/flask-mailing) for legacy or [Flask-Mailman](https://github.com/waynerv/flask-mailman) for Django type implementation. | ||
|
||
Flask-Mailing is a fork of `Sabuhi's` Fastapi-Mail package, providing similar functionality. 99% of the work was done by him, and the fork was made mainly provide the same features and the apis for the Flask Microframework. | ||
|
||
##### Need help to create and deploy the test cases.(Urgent) | ||
# Downloads | ||
[![Downloads](https://pepy.tech/badge/flask-mailing)](https://pepy.tech/project/flask-mailing) [![Downloads](https://pepy.tech/badge/flask-mailing/month)](https://pepy.tech/project/flask-mailing) [![Downloads](https://pepy.tech/badge/flask-mailing/week)](https://pepy.tech/project/flask-mailing) | ||
<br> | ||
|
||
|
||
### 🔨 Installation ### | ||
|
||
|
@@ -48,8 +53,8 @@ app.config['MAIL_USERNAME'] = "YourUserName" | |
app.config['MAIL_PASSWORD'] = "strong_password" | ||
app.config['MAIL_PORT'] = 587 | ||
app.config['MAIL_SERVER'] = "your mail server" | ||
app.config['MAIL_TLS'] = True | ||
app.config['MAIL_SSL'] = False | ||
app.config['MAIL_USE_TLS'] = True | ||
app.config['MAIL_USE_SSL'] = False | ||
app.config['USE_CREDENTIALS'] = True | ||
app.config['VALIDATE_CERTS'] = True | ||
app.config['MAIL_DEFAULT_SENDER'] = "[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,8 @@ def create_app(): | |
app.config['MAIL_PASSWORD'] = "world_top_secret_password" | ||
app.config['MAIL_PORT'] = 587 | ||
app.config['MAIL_SERVER'] = "your-email-server.com" | ||
app.config['MAIL_TLS'] = True | ||
app.config['MAIL_SSL'] = False | ||
app.config['MAIL_USE_TLS'] = True | ||
app.config['MAIL_USE_SSL'] = False | ||
mail.init_app(app) | ||
|
||
return app | ||
|
@@ -45,6 +45,13 @@ async def simple_send(): | |
return jsonify(status_code=200, content={"message": "email has been sent"}) | ||
``` | ||
|
||
#### Add recipient using `add_recipient` method | ||
|
||
```python | ||
message.add_recipient("[email protected]") | ||
``` | ||
|
||
|
||
### Send a simple html message | ||
```python | ||
|
||
|
@@ -81,6 +88,11 @@ async def mail_file(): | |
await mail.send_message(message) | ||
return jsonify(message="email sent") | ||
``` | ||
#### Sending files using `attach` method | ||
```python | ||
with app.open_resource("attachments/example.txt") as fp: | ||
message.attach("example.txt", fp.read()) | ||
``` | ||
|
||
### Using Jinja2 HTML Templates | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,8 @@ def create_app(): | |
app.config['MAIL_PASSWORD'] = "world_top_secret_password" | ||
app.config['MAIL_PORT'] = 587 | ||
app.config['MAIL_SERVER'] = "your-email-server.com" | ||
app.config['MAIL_TLS'] = True | ||
app.config['MAIL_SSL'] = False | ||
app.config['MAIL_USE_TLS'] = True | ||
app.config['MAIL_USE_SSL'] = False | ||
app.config['MAIL_DEFAULT_SENDER'] = "[email protected]" | ||
mail.init_app(app) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
from flask import Flask | ||
import os as os | ||
|
||
|
||
def create_app(): | ||
app = Flask(__name__) | ||
|
||
|
||
app.config['MAIL_USERNAME'] = "[email protected]" | ||
app.config['MAIL_PASSWORD'] = "" | ||
app.config['MAIL_USERNAME'] = os.environ['mu'] | ||
app.config['MAIL_PASSWORD'] = os.environ['mp'] | ||
app.config['MAIL_FROM'] = "[email protected]" | ||
app.config['MAIL_PORT'] = 587 | ||
app.config['MAIL_SERVER'] = "smtp.gmail.com" | ||
app.config['MAIL_TLS'] = True | ||
app.config['MAIL_SSL'] = False | ||
app.config['MAIL_PORT'] = os.environ['mport'] | ||
app.config['MAIL_SERVER'] = os.environ['ms'] | ||
app.config['MAIL_USE_TLS'] = True | ||
app.config['MAIL_USE_SSL'] = False | ||
# app.config['MAIL_TEMPLATE_FOLDER'] = Path(__file__).parent / 'attachments' | ||
|
||
return app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
from dotenv import load_dotenv; load_dotenv() | ||
|
||
from flask import jsonify | ||
from base import create_app | ||
from flask_mailing import Mail, Message | ||
|
||
import os as os | ||
|
||
mail = Mail() | ||
|
||
|
||
|
@@ -24,10 +28,10 @@ async def simple_send() -> jsonify: | |
|
||
message = Message( | ||
subject="Flask-Mailing module", | ||
recipients=["[email protected]"], | ||
recipients=[os.environ['MAIL_RECIPIENT']], | ||
body="This is the basic email body", | ||
# subtype="html" | ||
) | ||
message.add_recipient("[email protected]") | ||
|
||
|
||
await mail.send_message(message) | ||
|
@@ -38,10 +42,13 @@ async def simple_send() -> jsonify: | |
async def mail_file(): | ||
message = Message( | ||
subject = "attachments based email", | ||
recipients = ["[email protected]"], | ||
recipients = [os.environ['MAIL_RECIPIENT']], | ||
body = "This is the email body", | ||
attachments = ['attachments/attachment.txt'] | ||
) | ||
with app.open_resource('attachments/test.html') as fp: | ||
message.attach("test.html", fp.read()) | ||
|
||
await mail.send_message(message) | ||
return jsonify(message="email sent") | ||
|
||
|
@@ -50,7 +57,7 @@ async def mail_html(): | |
|
||
message = Message( | ||
subject = "html template based email", | ||
recipients = ["[email protected]"], | ||
recipients = [os.environ['MAIL_RECIPIENT']], | ||
template_body = { | ||
"first_name": "Fred", | ||
"last_name": "Fredsson" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
from setuptools import setup,find_packages | ||
from setuptools import ( | ||
setup, | ||
find_packages | ||
) | ||
|
||
version = (0, 0, 5) | ||
author = "Aniket Sarkar" | ||
VERSION = (0, 0, 5) | ||
AUTHOR = "Aniket Sarkar" | ||
AUTHOR_EMAIL = "[email protected]" | ||
|
||
|
||
with open("README.md", "r") as f: | ||
|
@@ -10,11 +14,11 @@ | |
|
||
setup( | ||
name="Flask-Mailing", | ||
version=".".join([str(i) for i in list(version)]), | ||
version=".".join([str(i) for i in list(VERSION)]), | ||
url="https://github.com/marktennyson/flask-mailing", | ||
license="MIT", | ||
author=author, | ||
author_email="[email protected]", | ||
author=AUTHOR, | ||
author_email=AUTHOR_EMAIL, | ||
description="Flask mail system sending mails(individual, bulk) attachments(individual, bulk) fully asynchroniously", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
|
Oops, something went wrong.