# Download Raw Received Email

> GET /emails/receiving/:id/raw — download the original RFC 822 .eml bytes for a received email.

`GET /emails/receiving/:id/raw`

Downloads the original RFC 822 message bytes for a received email. Unlike most API endpoints, this route does **not** return a JSON object — the response body is the raw `.eml` binary. The response carries:

- `Content-Type: message/rfc822`
- `Content-Disposition: attachment; filename="<id>.eml"`
- `X-Content-Type-Options: nosniff`

The SDK method `mb.emails.receiving.getRaw(id)` returns an **`ArrayBuffer`** containing the raw bytes. Parse or save it as a binary file — do not treat it as JSON.

Not every received email has stored raw bytes; if the original message was not retained, the endpoint returns `not_found`.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | The id of the received email. |

**Node.js**

```js
import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.emails.receiving.getRaw('4ef9a417-02e9-4d39-ad75-9611e0fcc33c');
console.log({ data, error });
```

**Ruby**

```ruby
require "mailblastr"

Mailblastr.api_key = "mb_xxxxxxxxx"

Mailblastr::Emails::Receiving.raw("4ef9a417-02e9-4d39-ad75-9611e0fcc33c")
```

**PHP**

```php
$mailblastr = Mailblastr::client('mb_xxxxxxxxx');

$mailblastr->emails->receiving->getRaw('4ef9a417-02e9-4d39-ad75-9611e0fcc33c');
```

**Python**

```python
import mailblastr

mailblastr.api_key = "mb_xxxxxxxxx"

mailblastr.Emails.Receiving.raw("4ef9a417-02e9-4d39-ad75-9611e0fcc33c")
```

**Go**

```go
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.mailblastr.com/emails/receiving/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/raw", nil)
    req.Header.Set("Authorization", "Bearer mb_xxxxxxxxx")
    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    out, _ := io.ReadAll(res.Body)
    fmt.Println(string(out))
}
```

**Rust**

```rust
use reqwest::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let res = Client::new()
        .get("https://api.mailblastr.com/emails/receiving/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/raw")
        .header("Authorization", "Bearer mb_xxxxxxxxx")
        .send()
        .await?;
    println!("{}", res.text().await?);
    Ok(())
}
```

**Java**

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.mailblastr.com/emails/receiving/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/raw"))
    .header("Authorization", "Bearer mb_xxxxxxxxx")
    .method("GET", HttpRequest.BodyPublishers.noBody())
    .build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

**.NET**

```csharp
using System.Net.Http;
using System.Text;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://api.mailblastr.com/emails/receiving/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/raw");
request.Headers.Add("Authorization", "Bearer mb_xxxxxxxxx");
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

**cURL**

```bash
curl -X GET 'https://api.mailblastr.com/emails/receiving/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/raw' \
  -H 'Authorization: Bearer mb_xxxxxxxxx'
```

**CLI**

```bash
mailblastr emails receiving raw 4ef9a417-02e9-4d39-ad75-9611e0fcc33c
```

## Response

On success the response body is the raw RFC 822 message bytes (binary, not JSON). Save or stream the body as a `.eml` file.

```bash
HTTP/1.1 200 OK
Content-Type: message/rfc822
Content-Disposition: attachment; filename="4ef9a417-02e9-4d39-ad75-9611e0fcc33c.eml"
X-Content-Type-Options: nosniff

<raw RFC 822 message bytes>
```

Returns `not_found` (404) if the received email does not exist for your account, or if no raw message was stored for it. See the [error reference](https://www.mailblastr.com/docs/api/errors).
