| Crates.io | stalwart_mta_hook_types |
| lib.rs | stalwart_mta_hook_types |
| version | 0.1.1 |
| created_at | 2025-06-16 10:05:59.304459+00 |
| updated_at | 2025-06-16 10:12:29.95154+00 |
| description | Rust type definitions for Stalwart Mail Transfer Agent (MTA) hooks |
| homepage | https://github.com/enaut/stalwart-mta-hook-types |
| repository | https://github.com/enaut/stalwart-mta-hook-types |
| max_upload_size | |
| id | 1714102 |
| size | 45,297 |
Rust type definitions for Stalwart Mail Transfer Agent (MTA) hooks. This crate provides strongly-typed request and response structures for implementing external hooks in Stalwart Mail Server.
See also: https://stalw.art/docs/api/mta-hooks/overview
This crate defines the data structures used for communication between Stalwart Mail Server and external hook implementations. It provides:
serdeAdd this to your Cargo.toml:
[dependencies]
stalwart_mta_hook_types = "0.1"
use stalwart_mta_hook_types::{Request, Response, Action, Modification};
// Parse an incoming hook request
let request: Request = serde_json::from_str(json_data)?;
// Create a response that accepts the email with modifications
let response = Response {
action: Action::Accept,
response: None,
modifications: vec![
Modification::add_header("X-Processed-By".to_string(), "My Hook".to_string()),
Modification::add_recipient("backup@example.com".to_string()),
],
};
// Serialize response back to JSON
let response_json = serde_json::to_string(&response)?;
use stalwart_mta_hook_types::{Response, Action, SmtpResponse};
let response = Response {
action: Action::Reject,
response: Some(SmtpResponse {
status: Some(550),
enhanced_status: Some("5.7.1".to_string()),
message: Some("Message rejected by policy".to_string()),
disconnect: false,
}),
modifications: vec![],
};
Represents an incoming hook request from Stalwart MTA:
pub struct Request {
pub context: Context,
pub envelope: Option<Envelope>,
pub message: Option<Message>,
}
The context contains information about the SMTP session, client connection, and server details.
Represents the hook's response back to Stalwart MTA:
pub struct Response {
pub action: Action,
pub response: Option<SmtpResponse>,
pub modifications: Vec<Modification>,
}
For the functionality available see the stalwart documentation at: https://stalw.art/docs/api/mta-hooks/overview
This project is licensed under the AGPL-3.0 license.
This crate is part of a larger SoLaWi (Solidarische Landwirtschaft) management system.
Based on Stalwart Mail Server hook types:
Both licensed under AGPL-3.0-only.