
Security News
The Nightmare Before Deployment
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.
flask-mailjet
Advanced tools
A lightweight, secure, and production-ready Flask extension for sending
emails through the Mailjet API, built on top of the official
mailjet-rest library.
MAILJET_API_KEY and MAILJET_API_SECRETpip install flask-mailjet
Add the following to your Flask application configuration:
app.config["MAILJET_API_KEY"] = "YOUR_API_KEY"
app.config["MAILJET_API_SECRET"] = "YOUR_API_SECRET"
Variable Description
MAILJET_API_KEY Your Mailjet API Public Key
MAILJET_API_SECRET Your Mailjet API Secret Key
from flask import Flask
from flask_mailjet import Mailjet
app = Flask(__name__)
app.config["MAILJET_API_KEY"] = "YOUR_API_KEY"
app.config["MAILJET_API_SECRET"] = "YOUR_API_SECRET"
mailjet = Mailjet(app)
from flask_mailjet import Mailjet
mailjet = Mailjet()
def create_app():
app = Flask(__name__)
app.config.from_mapping(
MAILJET_API_KEY="YOUR_API_KEY",
MAILJET_API_SECRET="YOUR_API_SECRET",
)
mailjet.init_app(app)
return app
All mail‑sending methods expect the sender field as:
{"Email": "sender@example.com", "Name": "Sender Name"}
from_user = {"Email": "alerts@app.com", "Name": "App Alerts"}
to_user = ["user1@mail.com", "user2@mail.com"]
mailjet.send_email(
sender=from_user,
recipients=to_user,
subject="Your Account Is Active",
html="<h1>Welcome!</h1><p>Your subscription is confirmed.</p>"
)
import os
pdf_path = os.path.join(app.root_path, "static", "invoice.pdf")
with open(pdf_path, "rb") as f:
pdf_bytes = f.read()
mailjet.send_email_with_attachment(
sender={"Email": "billing@app.com"},
recipients="client@corp.com",
subject="Q4 Financial Report",
html="<p>Attached is the report.</p>",
filename="Q4_Report.pdf",
file_bytes=pdf_bytes,
content_type="application/pdf",
)
You can render email templates stored in:
flask_mailjet/templates/mailjet/
from flask_mailjet.loader import render_email_template
email_html = render_email_template(
"welcome.html",
user_name="Tim",
link="https://app.example.com"
)
mailjet.send_email(
sender={"Email": "system@app.com"},
recipients="user@app.com",
subject="Welcome!",
html=email_html,
)
yourapp/
├── app.py
├── templates/
│ └── mailjet/
│ └── welcome.html
└── extensions/
└── mailjet.py
You can mock Mailjet easily using Python's builtin tools:
from unittest.mock import patch
@patch("flask_mailjet.Mailjet.send_email")
def test_send(mock_send):
mock_send.return_value = {"Status": "success"}
MIT License.
Pull requests are welcome.
Please open an issue first to discuss major changes.
If this extension helps you, consider starring the repository!
FAQs
A Flask extension for sending emails via Mailjet API.
We found that flask-mailjet demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.

Research
/Security News
Impostor NuGet package Tracer.Fody.NLog typosquats Tracer.Fody and its author, using homoglyph tricks, and exfiltrates Stratis wallet JSON/passwords to a Russian IP address.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.