API reference¶
The reference is generated from the source with mkdocstrings.
Root package¶
mxraven ¶
The official Python SDK for the mxRaven mail runtime.
The root package exposes SMTP submission. The webhook and feedback runtime
surfaces live in :mod:mxraven.webhook and :mod:mxraven.feedback.
Control-plane administration (tenants, domains, suppressions, analytics) is out of scope and is served by the separate mxRaven control-plane SDK.
Attachment
dataclass
¶
Attachment(
filename: str = "",
content_type: str = "",
data: bytes = b"",
inline: bool = False,
content_id: str = "",
)
A message attachment.
Attributes:
| Name | Type | Description |
|---|---|---|
filename |
str
|
The attachment filename. It may be empty. |
content_type |
str
|
The media type; defaults to |
data |
bytes
|
The raw attachment content. The caller retains ownership; it is not mutated. |
inline |
bool
|
Whether the attachment is meant for inline display, for example
an image referenced by |
content_id |
str
|
The inline content identifier, ignored unless |
Client ¶
Client(
host: str,
*,
port: int = DEFAULT_ADDRESS_PORT,
username: str,
secret: str,
tls: SSLContext | None = None,
pool_size: int = _DEFAULT_POOL_SIZE,
connect_timeout: float = _DEFAULT_CONNECT_TIMEOUT,
read_timeout: float = _DEFAULT_READ_TIMEOUT,
write_timeout: float = _DEFAULT_WRITE_TIMEOUT,
local_name: str | None = None,
starttls: bool = True,
require_tls: bool = True,
implicit_tls: bool = False,
local_address: str | None = None,
auth_mechanisms: Sequence[str] = (),
)
Submits mail to the mxRaven SMTP submission service.
A client maintains a bounded pool of authenticated connections. Use it as
a context manager or call :meth:close to release them.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
The submission server host; a port must not be included. |
required |
port
|
int
|
The submission server port. Defaults to |
DEFAULT_ADDRESS_PORT
|
username
|
str
|
The submission API key username. |
required |
secret
|
str
|
The submission API key secret. |
required |
tls
|
SSLContext | None
|
A custom STARTTLS |
None
|
pool_size
|
int
|
The maximum number of pooled connections. Defaults to |
_DEFAULT_POOL_SIZE
|
connect_timeout
|
float
|
The TCP connect timeout in seconds. |
_DEFAULT_CONNECT_TIMEOUT
|
read_timeout
|
float
|
The per-reply read timeout in seconds. |
_DEFAULT_READ_TIMEOUT
|
write_timeout
|
float
|
The per-write timeout in seconds. |
_DEFAULT_WRITE_TIMEOUT
|
local_name
|
str | None
|
The name sent in |
None
|
starttls
|
bool
|
Whether to issue |
True
|
require_tls
|
bool
|
Whether to fail when |
True
|
implicit_tls
|
bool
|
Whether the connection uses TLS from the first byte
(SMTPS, typically port 465). When true, |
False
|
local_address
|
str | None
|
An optional local bind address, |
None
|
auth_mechanisms
|
Sequence[str]
|
Preferred SASL mechanisms in order. When empty, the
client prefers |
()
|
Raises:
| Type | Description |
|---|---|
ValueError
|
A required argument is missing or invalid. |
Initialize the client and its connection pool.
Source code in src/mxraven/client.py
__enter__ ¶
__exit__ ¶
close ¶
send ¶
Submit a composed message and return the server's result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
Message
|
The message to submit. It may be sent more than once. |
required |
Returns:
| Type | Description |
|---|---|
Result
|
The server's result for the submission, including the mxRaven |
Result
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
|
ValueError
|
The message cannot be built. |
SMTPError
|
The server rejected a command. |
SMTPTransactionError
|
Every recipient was rejected; the
per-recipient detail is on the exception's |
Source code in src/mxraven/client.py
send_raw ¶
send_raw(
envelope: Envelope,
data: bytes | bytearray | memoryview | Iterable[bytes],
*,
prefer_bdat: bool = False,
) -> Result
Stream an already serialized RFC 5322 message with an explicit envelope.
The message is not parsed, so the caller is responsible for RFC 5322 correctness. Prefer this for large or pre-rendered messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
envelope
|
Envelope
|
The SMTP envelope, independent of the message headers. |
required |
data
|
bytes | bytearray | memoryview | Iterable[bytes]
|
The complete message bytes, or an iterable of chunks that is
streamed through |
required |
prefer_bdat
|
bool
|
Whether to use |
False
|
Returns:
| Type | Description |
|---|---|
Result
|
The server's result for the submission. |
Raises:
| Type | Description |
|---|---|
TypeError
|
|
ValueError
|
The envelope has no recipients or an address is invalid. |
SMTPError
|
The server rejected a command. |
SMTPTransactionError
|
Every recipient was rejected. |
Source code in src/mxraven/client.py
Envelope
dataclass
¶
The SMTP envelope for a raw message.
Attributes:
| Name | Type | Description |
|---|---|---|
sender |
str
|
The envelope sender. An empty value requests a null reverse-path, which is appropriate for bounce messages. |
recipients |
tuple[str, ...]
|
At least one envelope recipient. |
FeedbackError ¶
Bases: MxRavenError
The feedback service returned a non-success response.
Initialize the error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_code
|
int
|
The HTTP response status. |
required |
message
|
str
|
The service's |
''
|
Source code in src/mxraven/errors.py
Header
dataclass
¶
A custom message header.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The header field name. |
value |
str
|
The header field value. It must not contain a line break. |
InvalidSignatureError ¶
Bases: WebhookError
A webhook request's HMAC signature did not match.
Message ¶
A mutable, chainable builder for an email message.
Chained methods return the receiver. Set both :meth:text and :meth:html
to produce a multipart/alternative body; attachments produce a
multipart/mixed body. Bcc recipients are added to the envelope but
not to the headers.
Example
Create an empty message builder.
Source code in src/mxraven/message.py
attach ¶
attach(attachment: Attachment) -> Self
Append an attachment.
Note
The attachment data is retained by reference until the message is sent. Callers must not mutate it in the meantime.
Source code in src/mxraven/message.py
attach_file ¶
Append a file attachment with an optional explicit content type.
attach_inline ¶
Append an inline attachment referenced by content_id from HTML.
Source code in src/mxraven/message.py
bcc ¶
build ¶
Serialize the message into bytes and its submission envelope.
Returns:
| Type | Description |
|---|---|
BuiltMessage
|
The serialized message and envelope. |
Raises:
| Type | Description |
|---|---|
ValueError
|
The message has no |
Source code in src/mxraven/message.py
cc ¶
date ¶
Set the Date header. When unset, the time of building is used.
A naive when is interpreted as UTC.
from_ ¶
Set the envelope sender and the From header.
The name is from_ because from is a Python keyword. The address may
include a display name, for example Acme <noreply@acme.example>.
Source code in src/mxraven/message.py
header ¶
html ¶
in_reply_to ¶
message_id ¶
null_sender ¶
Use a null reverse-path while keeping the From header.
Intended for bounce and other auto-generated messages. A From header
is still required for a valid message.
Source code in src/mxraven/message.py
references ¶
reply_to ¶
sender ¶
subject ¶
text ¶
MxRavenError ¶
Bases: Exception
Base class for every error raised by the mxRaven SDK.
RecipientResult
dataclass
¶
RecipientResult(
address: str,
accepted: bool,
error: MxRavenError | None = None,
)
Whether a single envelope recipient was accepted.
Attributes:
| Name | Type | Description |
|---|---|---|
address |
str
|
The recipient address as submitted, without angle brackets. |
accepted |
bool
|
Whether the server accepted the recipient. |
error |
MxRavenError | None
|
The rejection reason when |
Result
dataclass
¶
Result(
message_ref: str = "",
code: int = 0,
message: str = "",
recipients: tuple[RecipientResult, ...] = (),
)
The outcome of a submission.
Attributes:
| Name | Type | Description |
|---|---|---|
message_ref |
str
|
The mxRaven message reference parsed from the final
|
code |
int
|
The final SMTP reply code. |
message |
str
|
The final SMTP reply text. It is intended for humans and is not stable. |
recipients |
tuple[RecipientResult, ...]
|
Per-recipient acceptance, in envelope order. |
SMTPCapabilityError ¶
Bases: MxRavenError
The server does not support a feature the message requires.
SMTPConnectionError ¶
Bases: MxRavenError
A connection could not be established or was lost.
The underlying socket or TLS failure is preserved as :attr:__cause__.
SMTPError ¶
Bases: MxRavenError
An SMTP reply that rejected a command.
Inspect :attr:code or :attr:enhanced_code to make a delivery decision.
:attr:message is the server's human-readable text and is not stable.
Initialize the error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
int
|
The three-digit SMTP reply code. |
required |
message
|
str
|
The server's reply text. |
required |
enhanced_code
|
str
|
The RFC 3463 |
''
|
Source code in src/mxraven/errors.py
SMTPProtocolError ¶
Bases: MxRavenError
The server sent a reply the client could not parse.
SMTPTimeoutError ¶
Bases: SMTPConnectionError
An SMTP operation exceeded its deadline.
SMTPTransactionError ¶
SMTPTransactionError(message: str, result: Result)
Bases: MxRavenError
Every envelope recipient was rejected.
The per-recipient detail is available on :attr:result.
Initialize the error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
A human-readable summary. |
required |
result
|
Result
|
The transaction result, including each recipient's outcome. |
required |
Source code in src/mxraven/errors.py
WebhookError ¶
Bases: MxRavenError
Base class for webhook verification and decoding failures.
Asynchronous client¶
aio ¶
Asynchronous mxRaven mail runtime.
Exposes :class:mxraven.aio.Client, the asyncio counterpart of
:class:mxraven.Client, with the same semantics and error surface.
Client ¶
Client(
host: str,
*,
port: int = DEFAULT_ADDRESS_PORT,
username: str,
secret: str,
tls: SSLContext | None = None,
pool_size: int = _DEFAULT_POOL_SIZE,
connect_timeout: float = _DEFAULT_CONNECT_TIMEOUT,
read_timeout: float = _DEFAULT_READ_TIMEOUT,
write_timeout: float = _DEFAULT_WRITE_TIMEOUT,
local_name: str | None = None,
starttls: bool = True,
require_tls: bool = True,
implicit_tls: bool = False,
local_address: str | None = None,
auth_mechanisms: Sequence[str] = (),
)
Submits mail to the mxRaven SMTP submission service using asyncio.
A client maintains a bounded pool of authenticated connections. Use it as
an asynchronous context manager or call :meth:close.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
The submission server host; a port must not be included. |
required |
port
|
int
|
The submission server port. Defaults to |
DEFAULT_ADDRESS_PORT
|
username
|
str
|
The submission API key username. |
required |
secret
|
str
|
The submission API key secret. |
required |
tls
|
SSLContext | None
|
A custom STARTTLS |
None
|
pool_size
|
int
|
The maximum number of pooled connections. Defaults to |
_DEFAULT_POOL_SIZE
|
connect_timeout
|
float
|
The TCP connect timeout in seconds. |
_DEFAULT_CONNECT_TIMEOUT
|
read_timeout
|
float
|
The per-reply read timeout in seconds. |
_DEFAULT_READ_TIMEOUT
|
write_timeout
|
float
|
The per-write timeout in seconds. |
_DEFAULT_WRITE_TIMEOUT
|
local_name
|
str | None
|
The name sent in |
None
|
starttls
|
bool
|
Whether to issue |
True
|
require_tls
|
bool
|
Whether to fail when |
True
|
implicit_tls
|
bool
|
Whether the connection uses TLS from the first byte
(SMTPS, typically port 465). When true, |
False
|
local_address
|
str | None
|
An optional local bind address, |
None
|
auth_mechanisms
|
Sequence[str]
|
Preferred SASL mechanisms in order. |
()
|
Raises:
| Type | Description |
|---|---|
ValueError
|
A required argument is missing or invalid. |
Initialize the client and its connection pool.
Source code in src/mxraven/aio/client.py
__aenter__
async
¶
__aexit__
async
¶
close
async
¶
send
async
¶
Submit a composed message and return the server's result.
Raises:
| Type | Description |
|---|---|
TypeError
|
|
ValueError
|
The message cannot be built. |
SMTPError
|
The server rejected a command. |
SMTPTransactionError
|
Every recipient was rejected. |
Source code in src/mxraven/aio/client.py
send_raw
async
¶
send_raw(
envelope: Envelope,
data: bytes
| bytearray
| memoryview
| Iterable[bytes]
| AsyncIterable[bytes],
*,
prefer_bdat: bool = False,
) -> Result
Stream an already serialized RFC 5322 message with an explicit envelope.
Raises:
| Type | Description |
|---|---|
TypeError
|
|
ValueError
|
The envelope has no recipients or an address is invalid. |
SMTPError
|
The server rejected a command. |
SMTPTransactionError
|
Every recipient was rejected. |
Source code in src/mxraven/aio/client.py
Webhooks¶
webhook ¶
mxRaven webhook verification and decoding.
Verifies the X-MxRaven-* HMAC-SHA256 signature over the canonical request
string and decodes DELIVER_WEBHOOK (inbound email) and NOTIFY_WEBHOOK
(SMTP or object-storage delivery status) payloads.
Example
DeliveryStatus
dataclass
¶
DeliveryStatus(
task_id: str = "",
tenant_id: str = "",
listener_id: str = "",
status: str = "",
attempt: int = 0,
accepted_at_utc: int = 0,
occurred_at_utc: int = 0,
source_ip: str = "",
destination_domain: str = "",
remote_host: str = "",
smtp_code: int = 0,
enhanced_status_code: str = "",
remote_response: str = "",
next_retry_at_utc: int = 0,
correlation_task_id: str = "",
)
The SMTP NOTIFY_WEBHOOK payload.
Envelope
dataclass
¶
The SMTP envelope of a message.
Event
dataclass
¶
Event(
type: EventType,
inbound_email: InboundEmail | None = None,
delivery_status: DeliveryStatus | None = None,
storage_status: StorageStatus | None = None,
)
A decoded webhook delivery.
Exactly one of inbound_email, delivery_status, or storage_status is
set, matching type.
EventType ¶
Bases: StrEnum
The shape of a decoded webhook payload.
InboundEmail
dataclass
¶
InboundEmail(
event_type: str = "",
task_id: str = "",
tenant_id: str = "",
listener_id: str = "",
attempt: int = 0,
accepted_at_utc: int = 0,
occurred_at_utc: int = 0,
routing_decision: RoutingDecision | None = None,
verdicts: Verdicts | None = None,
envelope: Envelope = Envelope(),
message: MessageSummary = MessageSummary(),
headers: tuple[HeaderField, ...] = (),
raw_email: RawEmail = RawEmail(),
)
The DELIVER_WEBHOOK payload: a complete inbound message.
InvalidSignatureError ¶
Bases: WebhookError
A webhook request's HMAC signature did not match.
MessageSummary
dataclass
¶
MessageSummary(
subject: str = "",
from_: tuple[str, ...] = (),
to: tuple[str, ...] = (),
cc: tuple[str, ...] = (),
message_id: str = "",
date: str = "",
)
A summary of the parsed message headers.
RawEmail
dataclass
¶
RawEmail(
url: str = "",
token_type: str = "",
access_token: str = "",
expires_at_utc: int = 0,
size_bytes: int = 0,
sha256_hex: str = "",
content_type: str = "",
)
Time-limited access to the raw RFC 822 message.
fetch ¶
Download and verify the raw message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
The request timeout in seconds. |
60.0
|
transport
|
SyncTransport | None
|
An optional transport to use instead of the default. |
None
|
Returns:
| Type | Description |
|---|---|
bytes
|
The verified raw message bytes. |
Raises:
| Type | Description |
|---|---|
WebhookError
|
The URL or token is missing, the response is not 200, the size does not match, or the SHA-256 digest does not match. |
Note
The raw-email access token is a secret; do not log it.
Source code in src/mxraven/webhook/payload.py
fetch_async
async
¶
Asynchronously download and verify the raw message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
The request timeout in seconds. |
60.0
|
transport
|
AsyncTransport | None
|
An optional transport to use instead of the default. |
None
|
Returns:
| Type | Description |
|---|---|
bytes
|
The verified raw message bytes. |
Raises:
| Type | Description |
|---|---|
WebhookError
|
The URL or token is missing, the response is not 200, the size does not match, or the SHA-256 digest does not match. |
Note
The raw-email access token is a secret; do not log it.
Source code in src/mxraven/webhook/payload.py
RoutingDecision
dataclass
¶
RoutingDecision(
terminal_action: str = "",
matched_rule_id: str = "",
used_listener_default: bool = False,
)
The final routing outcome for an inbound message.
Attributes:
| Name | Type | Description |
|---|---|---|
terminal_action |
str
|
The final terminal action. Compare it against the
:class: |
matched_rule_id |
str
|
The rule that selected the action, when one matched. |
used_listener_default |
bool
|
Whether the listener default was used. |
StatusOutcome ¶
Bases: StrEnum
The lifecycle state reported by a delivery status webhook.
StorageStatus
dataclass
¶
StorageStatus(
event_type: str = "",
task_id: str = "",
tenant_id: str = "",
listener_id: str = "",
status: str = "",
attempt: int = 0,
accepted_at_utc: int = 0,
occurred_at_utc: int = 0,
storage_ref: str = "",
bucket_name: str = "",
object_key: str = "",
endpoint_host: str = "",
status_code: int = 0,
error_code: str = "",
message: str = "",
next_retry_at_utc: int = 0,
)
The object-storage NOTIFY_WEBHOOK payload.
TerminalAction ¶
Bases: StrEnum
The final routing action recorded for an inbound message.
Verdicts
dataclass
¶
Verdicts(
action: str = "",
score: float = 0.0,
required_score: float = 0.0,
is_spam: bool = False,
has_malware: bool = False,
malware_names: tuple[str, ...] = (),
is_skipped: bool = False,
error: str = "",
)
Spam and malware scan results.
Verifier ¶
Verifier(
*,
secret: str = "",
keys: Mapping[str, str] | None = None,
tolerance: float = _DEFAULT_TOLERANCE,
max_body_bytes: int = _DEFAULT_MAX_BODY,
clock: Callable[[], float] | None = None,
)
Verifies the signature of an mxRaven webhook request.
A verifier is safe for concurrent use once constructed. Configure it with a signing secret, with per-key secrets for rotation, or both.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
secret
|
str
|
The signing secret, used as literal bytes and never decoded. |
''
|
keys
|
Mapping[str, str] | None
|
Per-key secrets for rotation, keyed by signing key ID. |
None
|
tolerance
|
float
|
The maximum accepted clock skew in seconds; |
_DEFAULT_TOLERANCE
|
max_body_bytes
|
int
|
The maximum body size in bytes. Defaults to 1 MiB. |
_DEFAULT_MAX_BODY
|
clock
|
Callable[[], float] | None
|
A callable returning the current Unix time; used for testing. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
No secret was supplied or an option is invalid. |
Initialize the verifier.
Source code in src/mxraven/webhook/verifier.py
verify ¶
verify(request: WebhookRequest) -> None
Verify a request's signature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
WebhookRequest
|
The inbound request. |
required |
Raises:
| Type | Description |
|---|---|
InvalidSignatureError
|
The signature does not match. |
WebhookError
|
A required header is missing, the timestamp is stale, or the body exceeds the configured limit. |
Source code in src/mxraven/webhook/verifier.py
verify_and_decode ¶
verify_and_decode(request: WebhookRequest) -> Event
Verify a request and decode its payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
WebhookRequest
|
The inbound request. |
required |
Returns:
| Type | Description |
|---|---|
Event
|
The decoded event. |
Raises:
| Type | Description |
|---|---|
InvalidSignatureError
|
The signature does not match. |
WebhookError
|
Verification or decoding failed. |
Source code in src/mxraven/webhook/verifier.py
WebhookError ¶
Bases: MxRavenError
Base class for webhook verification and decoding failures.
WebhookRequest
dataclass
¶
The parts of an inbound HTTP request the signature covers.
Header names are stored lowercased so lookups are case-insensitive.
Attributes:
| Name | Type | Description |
|---|---|---|
method |
str
|
The HTTP method. |
url |
str
|
The public URL the caller used, including scheme and host. |
headers |
Mapping[str, str]
|
The request headers keyed by lowercase name. |
body |
bytes
|
The exact raw request body bytes. |
create
classmethod
¶
create(
method: str,
url: str,
headers: Mapping[str, str],
body: bytes | bytearray | memoryview = b"",
) -> WebhookRequest
Build a request, normalizing header names and body type.
Source code in src/mxraven/webhook/request.py
from_asgi
classmethod
¶
from_asgi(
scope: Mapping[str, object], body: bytes
) -> WebhookRequest
Build a request from an ASGI scope and pre-read body.
Source code in src/mxraven/webhook/request.py
from_wsgi
classmethod
¶
from_wsgi(environ: Mapping[str, object]) -> WebhookRequest
Build a request from a WSGI environ.
Note
The signature covers the exact raw body and the public URL, so read the body here rather than letting a framework parse it first.
Source code in src/mxraven/webhook/request.py
Feedback¶
feedback ¶
mxRaven recipient feedback.
Teaches the spam filter with tenant-supplied raw messages and performs RFC 8058 one-click unsubscribes.
AsyncClient ¶
AsyncClient(
base_url: str,
*,
username: str = "",
secret: str = "",
timeout: float = _DEFAULT_TIMEOUT,
transport: AsyncTransport | None = None,
)
Calls the mxRaven feedback service using asyncio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
The feedback service base URL. |
required |
username
|
str
|
The submission API key username, used for learning. |
''
|
secret
|
str
|
The submission API key secret, used for learning. |
''
|
timeout
|
float
|
The request timeout in seconds. Defaults to |
_DEFAULT_TIMEOUT
|
transport
|
AsyncTransport | None
|
An optional asynchronous HTTP transport. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Initialize the client.
Source code in src/mxraven/feedback/client.py
learn
async
¶
learn(
disposition: Disposition,
raw_mime: bytes | bytearray | memoryview,
) -> LearningResult
Submit one training example asynchronously.
Source code in src/mxraven/feedback/client.py
learn_ham
async
¶
learn_ham(
raw_mime: bytes | bytearray | memoryview,
) -> LearningResult
Teach the spam filter that raw_mime is not spam.
learn_spam
async
¶
learn_spam(
raw_mime: bytes | bytearray | memoryview,
) -> LearningResult
unsubscribe
async
¶
Perform an RFC 8058 one-click unsubscribe for token.
Source code in src/mxraven/feedback/client.py
Client ¶
Client(
base_url: str,
*,
username: str = "",
secret: str = "",
timeout: float = _DEFAULT_TIMEOUT,
transport: SyncTransport | None = None,
)
Calls the mxRaven feedback service synchronously.
A client is safe for concurrent use.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
The feedback service base URL, for example
|
required |
username
|
str
|
The submission API key username, used for learning. |
''
|
secret
|
str
|
The submission API key secret, used for learning. |
''
|
timeout
|
float
|
The request timeout in seconds. Defaults to |
_DEFAULT_TIMEOUT
|
transport
|
SyncTransport | None
|
An optional HTTP transport to use instead of the default. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Initialize the client.
Source code in src/mxraven/feedback/client.py
learn ¶
learn(
disposition: Disposition,
raw_mime: bytes | bytearray | memoryview,
) -> LearningResult
Submit one training example.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
disposition
|
Disposition
|
The training label. |
required |
raw_mime
|
bytes | bytearray | memoryview
|
The exact raw RFC 822 bytes mxRaven processed; the service matches them against stored evidence by SHA-256. |
required |
Returns:
| Type | Description |
|---|---|
LearningResult
|
The service's learning result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Credentials are missing or the disposition is invalid. |
FeedbackError
|
The service returned a non-success response. |
Source code in src/mxraven/feedback/client.py
learn_ham ¶
learn_ham(
raw_mime: bytes | bytearray | memoryview,
) -> LearningResult
learn_spam ¶
learn_spam(
raw_mime: bytes | bytearray | memoryview,
) -> LearningResult
unsubscribe ¶
Perform an RFC 8058 one-click unsubscribe for token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
The unsubscribe token from the |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
The token is empty. |
FeedbackError
|
The service returned a non-success response. |
Source code in src/mxraven/feedback/client.py
Disposition ¶
Bases: StrEnum
The training label for a message.
FeedbackError ¶
Bases: MxRavenError
The feedback service returned a non-success response.
Initialize the error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_code
|
int
|
The HTTP response status. |
required |
message
|
str
|
The service's |
''
|
Source code in src/mxraven/errors.py
LearningResult
dataclass
¶
LearningResult(
status: str = "",
disposition: str = "",
tenant_id: str = "",
listener_id: str = "",
matched_hash_kind: str = "",
)
The outcome of a successful learning request.
Attributes:
| Name | Type | Description |
|---|---|---|
status |
str
|
The service status, normally |
disposition |
str
|
The training label that was applied. |
tenant_id |
str
|
The tenant that owns the matched message. |
listener_id |
str
|
The listener that processed the matched message. |
matched_hash_kind |
str
|
Which stored hash matched the submitted bytes. |