Skip to main content

A Simple SMTP Email sender crate with the support of sync or async sending. Can be called from Python. Powered by PyO3.

Project description

simple_smtp_sender

A Simple SMTP Email sender crate with the support of sync or async sending. Can be called from Python. Powered by powered by Rust, lettre and PyO3.

Overview

This project provides rust crate and a Python extension module implemented in Rust for sending emails via SMTP, including support for attachments, CC, and BCC. There are methods for both synchronous and asynchronous sending. It leverages the performance and safety of Rust, exposes a convenient Python API, and is built using PyO3 and lettre. The python module is compatible with Python 3.10 and above.

Features

  • Send emails via SMTP synchronously or asynchronously
  • Support HTML email contents
  • Attach files to emails
  • Support for CC and BCC
  • Secure authentication
  • Easy configuration via Python class

Installation

from PyPI

uv pip install simple_smtp_sender
# or
pip install simple_smtp_sender

from source (requires Rust toolchain and maturin)

git clone https://github.com/guangyu-he/simple_smtp_sender.git
cd simple_smtp_sender
# prepare venv and maturin if needed
maturin develop

Or build a wheel:

maturin build
pip install target/wheels/config_lang_serder-*.whl

Requirements

  • Python >= 3.10
  • Rust toolchain (for building)

Usage

An example test from Rust crate:

use simple_smtp_sender::{send_email_async, send_email_sync, EmailConfig};

#[test]
fn send_email_sync_test() {
    let config = EmailConfig::new(
        "smtp.example.com",
        "your@email.com",
        "your_username",
        "your_password",
    );
    let result = send_email_sync(config, vec!["recipient@email.com"], "Test Email", "Hello from Rust!", None, None, None);
    assert!(result.is_ok());
}

#[tokio::test]
fn send_email_async_test() {
    let config = EmailConfig::new(
        "smtp.example.com",
        "your@email.com",
        "your_username",
        "your_password",
    );
    let result = send_email_async(config, vec!["recipient@email.com"], "Test Email", "Hello from Rust!", None, None, None).await;
    assert!(result.is_ok());
}

An example from Python API:

from simple_smtp_sender import EmailConfig, send_email, async_send_email

config = EmailConfig(
    server="smtp.example.com",
    sender_email="your@email.com",
    username="your_username",
    password="your_password",
)

# Synchronous send (blocking)
send_email(
    config,
    recipient=["recipient@email.com"],
    subject="Test Email",
    body="Hello from Rust!",
)

# With attachment, CC, and BCC:
send_email(
    config,
    recipient=["recipient@email.com"],
    subject="With Attachment",
    body="See attached file.",
    cc=["cc@email.com"],
    bcc=["bcc@email.com"],
    attachment="/path/to/file.pdf",
)

# Asynchronous send (non-blocking)
import asyncio


async def main():
    await async_send_email(
        config,
        recipient=["recipient@email.com"],
        subject="Async Email",
        body="Sent asynchronously!",
    )


asyncio.run(main())

API

EmailConfig

Configuration class for SMTP server and credentials.

  • server: SMTP server URL
  • sender_email: Sender's email address
  • username: SMTP username
  • password: SMTP password

send_email(config, recipient, subject, body, cc=None, bcc=None, attachment=None)

Sends an email synchronously (blocking) using the provided configuration.

  • config: EmailConfig instance
  • recipient: List of recipient email(s)
  • subject: Email subject
  • body: Email body
  • cc: List of CC recipients (optional)
  • bcc: List of BCC recipients (optional)
  • attachment: Path to file to attach (optional)

async_send_email(config, recipient, subject, body, cc=None, bcc=None, attachment=None)

Sends an email asynchronously (non-blocking, returns an awaitable).

  • config: EmailConfig instance
  • recipient: List of recipient email(s)
  • subject: Email subject
  • body: Email body
  • cc: List of CC recipients (optional)
  • bcc: List of BCC recipients (optional)
  • attachment: Path to file to attach (optional)

Development

  • Rust dependencies are managed in Cargo.toml.
  • Python build configuration is in pyproject.toml.
  • Main Rust logic in src/.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_smtp_sender-0.2.2.tar.gz (27.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

simple_smtp_sender-0.2.2-cp310-abi3-win_amd64.whl (717.1 kB view details)

Uploaded CPython 3.10+Windows x86-64

simple_smtp_sender-0.2.2-cp310-abi3-win32.whl (672.0 kB view details)

Uploaded CPython 3.10+Windows x86

simple_smtp_sender-0.2.2-cp310-abi3-musllinux_1_2_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

simple_smtp_sender-0.2.2-cp310-abi3-musllinux_1_2_i686.whl (3.2 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ i686

simple_smtp_sender-0.2.2-cp310-abi3-musllinux_1_2_armv7l.whl (3.0 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARMv7l

simple_smtp_sender-0.2.2-cp310-abi3-musllinux_1_2_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

simple_smtp_sender-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

simple_smtp_sender-0.2.2-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (3.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ i686

simple_smtp_sender-0.2.2-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (2.6 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARMv7l

simple_smtp_sender-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.3 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

simple_smtp_sender-0.2.2-cp310-abi3-macosx_11_0_arm64.whl (852.8 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

simple_smtp_sender-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl (870.4 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file simple_smtp_sender-0.2.2.tar.gz.

File metadata

  • Download URL: simple_smtp_sender-0.2.2.tar.gz
  • Upload date:
  • Size: 27.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.8.6

File hashes

Hashes for simple_smtp_sender-0.2.2.tar.gz
Algorithm Hash digest
SHA256 43170883f358919b3773fd34be4954b54f776680e23542a9f3c792837ead3955
MD5 a61b0d45d46d7ffc9ab4871626e6fed7
BLAKE2b-256 2bbab3f2e971eb377e80fd1bebc75ab4b802946e2de7845cbe5252b501a4b0bc

See more details on using hashes here.

File details

Details for the file simple_smtp_sender-0.2.2-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for simple_smtp_sender-0.2.2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ea0054be365a200bb89ba85a793ccf664a08eeee0848662bde283ea064989c6e
MD5 708035e1a8e39484f31c863a7d2c6955
BLAKE2b-256 1e2f29211682fbd649f7139f42a9037dc1325e016c091fb58f050b8addc2b346

See more details on using hashes here.

File details

Details for the file simple_smtp_sender-0.2.2-cp310-abi3-win32.whl.

File metadata

File hashes

Hashes for simple_smtp_sender-0.2.2-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 b42b20babe4b2e2b30186b5633a604913db6d4da575dc811f801422ad23461a7
MD5 be3dd6a5aadb6c208d85ab3455ff4342
BLAKE2b-256 54af0b5f3b21718f6c7e293caca51f90343be6397f824b9e33b49498fd09c638

See more details on using hashes here.

File details

Details for the file simple_smtp_sender-0.2.2-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for simple_smtp_sender-0.2.2-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f1fdfdb4ffbb5de03cc57576c0f15de787c160d0b8e6d9e0e212c8d1850a4c10
MD5 91ec5475339efb6f398c080d71b56d1d
BLAKE2b-256 92e5336bfb1a5db4bd803529a684e8969e02fe1ec0d949bd35bdb880c072e01d

See more details on using hashes here.

File details

Details for the file simple_smtp_sender-0.2.2-cp310-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for simple_smtp_sender-0.2.2-cp310-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 e3bdab4e97bd0437e5e02c04bb3a7eee792748df6005699f0afcf015c2a23d48
MD5 ec9c7a3c7fbd6c2c2fe3705386e7a381
BLAKE2b-256 680cadff4316d720bbfdf80c90560a49639edf95b2966ea44a51426748314984

See more details on using hashes here.

File details

Details for the file simple_smtp_sender-0.2.2-cp310-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for simple_smtp_sender-0.2.2-cp310-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 6733ac41d49e37b8282f15f4c61010c11bae73dafc3b871868146d4a0cd275ef
MD5 3d12b25a9a68d1793d6cdf35afbbb478
BLAKE2b-256 2e955dbe987a85a1429e99551f40224aa32826f2a247f9aed8a50ecfc8d93747

See more details on using hashes here.

File details

Details for the file simple_smtp_sender-0.2.2-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for simple_smtp_sender-0.2.2-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 77169e42c27e4269eb7f671a3635416eebe5c0fa32f709e79d4a6f1c6b475e26
MD5 79bca327c29b61b67da74cc43995bc15
BLAKE2b-256 103c8027b58ddaf77a830d0cb4483f46ec321e9bb55ac48aa916c420c27dee09

See more details on using hashes here.

File details

Details for the file simple_smtp_sender-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for simple_smtp_sender-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9de3de83769a3326a0718c9f0fcb1281a2b7f851fcbbc259a2ceeb5d002ea175
MD5 8de44db365279ddb839450b5c38f96a4
BLAKE2b-256 83cb1ba031975edce476b9eadd0e533dc06b9e6ffd79411a8eb832ad14566914

See more details on using hashes here.

File details

Details for the file simple_smtp_sender-0.2.2-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for simple_smtp_sender-0.2.2-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 f40a9cca54ac6ebea745f88b143c178106b22a977fedb104b6c51db374d55cfb
MD5 e0caa962bbb8b8ddd08a551bf44bc5d4
BLAKE2b-256 19e6663224df4c5f035256eabc9043c25255675a522de264693d5eded4fae3cd

See more details on using hashes here.

File details

Details for the file simple_smtp_sender-0.2.2-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for simple_smtp_sender-0.2.2-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 91c12eec96d4064998eefca671411e4181e4a2b47ca74eb53b689130236efa5d
MD5 aa840dbfc519b8122e17933965ad06e6
BLAKE2b-256 1b9b0a92f636710df11c22607df3bff8399fdcb4a483aad78811b8e66433e6c5

See more details on using hashes here.

File details

Details for the file simple_smtp_sender-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for simple_smtp_sender-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b2d1467fbced194a594643843497a1a9d441b839b1c375d2f24bed52f311a668
MD5 3853b8ab2a73d1dbc3961d4b7379b203
BLAKE2b-256 6ded3eebf8a5c33c38750c39459d879f7a5852bfda697ed720ffd230a0043311

See more details on using hashes here.

File details

Details for the file simple_smtp_sender-0.2.2-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for simple_smtp_sender-0.2.2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9d5943df47c22663cf3ea5791a6606f00b5eed23f4c2cb41e851dee385a6a1d3
MD5 3e3d97d69e72bafde750f26731f17b73
BLAKE2b-256 c8daa020a055b7e7aee50abafd7eeb7008429a8779715a46e96acaa88976cbe2

See more details on using hashes here.

File details

Details for the file simple_smtp_sender-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for simple_smtp_sender-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1d6b7c15506ec9639eaf670af6c2dff846133a9cabeaf9762c06016faa33a0cb
MD5 1feb9c20878e9fe794ef3a0ed9a9f659
BLAKE2b-256 95deb7687bb3b8c44538643f8f65db0f2d5b8b49c7d4aa1a58833413a2f0edf5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page