pub struct EmailClient { /* private fields */ }Expand description
Talks to the smbCloud transactional email API.
Cheap to clone — the inner reqwest::Client is Arc-backed. Build one at
startup and clone it wherever you need it.
§Authentication
Every request carries Authorization: Bearer <api_key> from the
EmailCredentials. Mint a key for your Mail app in the smbCloud console;
sending is scoped to that app’s verified domain. Reading messages
(get_message, list_messages) needs a key with read scope.
Implementations§
Source§impl EmailClient
impl EmailClient
Sourcepub fn from_credentials(
environment: Environment,
credentials: EmailCredentials<'_>,
) -> Self
pub fn from_credentials( environment: Environment, credentials: EmailCredentials<'_>, ) -> Self
Build a client from an environment and credentials.
The base URL is resolved from the environment:
Environment::Dev→http://localhost:8088Environment::Production→https://api.smbcloud.xyz
Sourcepub async fn send(
&self,
message: &SendEmail,
) -> Result<EmailMessage, EmailError>
pub async fn send( &self, message: &SendEmail, ) -> Result<EmailMessage, EmailError>
Send a transactional email: POST /v1/email/messages.
Returns the created EmailMessage (status Sent). If the message
carried an idempotency_key that was already used, the original message
is returned and nothing is sent again.
Sourcepub async fn get_message(&self, id: &str) -> Result<EmailMessage, EmailError>
pub async fn get_message(&self, id: &str) -> Result<EmailMessage, EmailError>
Fetch one message by id with its delivery-event timeline:
GET /v1/email/messages/:id. Requires a read-scope key.
Sourcepub async fn list_messages(
&self,
status: Option<&str>,
limit: Option<u32>,
) -> Result<Vec<EmailMessage>, EmailError>
pub async fn list_messages( &self, status: Option<&str>, limit: Option<u32>, ) -> Result<Vec<EmailMessage>, EmailError>
List recent messages: GET /v1/email/messages. Requires a read-scope
key. status filters by delivery status name (e.g. "delivered");
limit is clamped server-side to 1..=100.