> ## Documentation Index
> Fetch the complete documentation index at: https://docs.paubox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Receiving client

> Full reference for the Paubox Rust SDK receiving API: managing domains, mailboxes, and retrieving inbound email.

The receiving methods are on the same `PauboxClient` you use to send email. They require the `email` feature (enabled by default).

```rust theme={null}
let client = PauboxClient::new("YOUR_API_KEY");
```

All methods are async and return `Result<T, PauboxError>`.

## Domains

### List domains

```rust theme={null}
let domains = client.list_receiving_domains().await?;
for d in &domains {
    println!("{}", d.domain.as_deref().unwrap_or(""));
}
```

### Create a domain

```rust theme={null}
let domain = client.create_receiving_domain(Some("support")).await?;
println!("{}", domain.domain.as_deref().unwrap_or("")); // support.inbound.paubox.email
```

Pass `None` to auto-generate a slug.

### Get a domain

```rust theme={null}
let domain = client.get_receiving_domain(1).await?;
```

### Delete a domain

```rust theme={null}
client.delete_receiving_domain(1).await?;
```

## Mailboxes

### List mailboxes

```rust theme={null}
let mailboxes = client.list_receiving_mailboxes(domain_id).await?;
```

### Create a mailbox

```rust theme={null}
let mailbox = client.create_receiving_mailbox(domain_id, "intake", "SecurePass123!", None).await?;
println!("{}", mailbox.email_address.unwrap_or_default());
```

Pass `Some(bytes)` as the fourth argument for a storage quota.

### Get a mailbox

```rust theme={null}
let mailbox = client.get_receiving_mailbox(domain_id, mailbox_id).await?;
```

### Delete a mailbox

```rust theme={null}
client.delete_receiving_mailbox(domain_id, mailbox_id).await?;
```

## Emails

### List received emails

```rust theme={null}
let resp = client.list_received_emails(Some(10), None, None).await?;
for e in &resp.data {
    println!("{}: {}", e.email_id, e.subject.as_deref().unwrap_or(""));
}

// Cursor pagination
let next = client.list_received_emails(
    None,
    resp.data.last().map(|e| e.email_id.as_str()),
    None,
).await?;
```

### Get a received email

```rust theme={null}
let email = client.get_received_email("eaaaaab").await?;
println!("{}", email.body_text.unwrap_or_default());
```

### Download an attachment

```rust theme={null}
let data: Vec<u8> = client.get_received_email_attachment("eaaaaab", "blob123").await?;
std::fs::write("report.pdf", &data)?;
```
