Expand description
§wangamail-rs
Send email on behalf of a Microsoft tenant using Microsoft Graph API
and app registration credentials (OAuth2 client credentials flow). Part of the WangaMail family
(wangamail-rs, wangamail-js, wangamail-py, wangamail-net).
Developed with love by 1nga Solutions · Logo: https://www.1nga.com/logo.svg
§Features
- Default: Build a
GraphMailClientand send mail withsend_mail. mcp: Optional Model Context Protocol server that exposes a send_email tool for AI assistants (Cursor, Claude Desktop, etc.). See the [mcp] module.
§Setup
- Register an application in Azure Portal → Microsoft Entra ID → App registrations.
- Create a client secret for the app.
- Under API permissions, add application permission Mail.Send for Microsoft Graph and grant admin consent.
- To send as a specific user, that user must have a mailbox in Exchange Online; the app sends as the user identified by
from_user(user id or userPrincipalName).
§Example
use wangamail_rs::{GraphMailClient, Message, BodyType, Recipient, SendMailRequest};
let client = GraphMailClient::builder()
.tenant_id("your-tenant-id")
.client_id("your-client-id")
.client_secret("your-client-secret")
.build()?;
let request = SendMailRequest::new(Message {
subject: "Hello from Graph".to_string(),
body: wangamail_rs::MessageBody {
content_type: BodyType::Text,
content: "This email was sent via Microsoft Graph.".to_string(),
},
to_recipients: vec![
Recipient::new("recipient@example.com"),
],
..Default::default()
});
client.send_mail("user@yourtenant.onmicrosoft.com", request).await?;§Modules
- [
mcp] (optional, featuremcp): MCP server and send_email tool for AI tool use.
Structs§
- Email
Address - Email address (address + optional display name).
- File
Attachment - File attachment (Graph fileAttachment; content as base64).
- Graph
Mail Client - Client for sending email via Microsoft Graph (app-only, client credentials).
- Graph
Mail Client Builder - Builder for
GraphMailClient. - Message
- Message payload for sendMail.
- Message
Body - Message body (content type + raw content).
- Recipient
- A single recipient (to, cc, or bcc).
- Send
Mail Request - Request body for
POST /users/{id}/sendMail.
Enums§
- Body
Type - Body content type for the message.
- Error
- Errors that can occur when using the Graph mail client or MCP server.
Type Aliases§
- Result
- Result type alias using this crate’s [
Error].