Extract email headers
Upload an email and get its headers.
Code example
import aiofiles
from pathlib import Path
from ptsandbox import Sandbox, SandboxKey
async def example() -> None:
sandbox = Sandbox(key=SandboxKey(...))
async with aiofiles.open("./email-headers", "wb") as fd:
async for chunk in sandbox.get_email_headers(Path("./email.bin")):
await fd.write(chunk)
ptsandbox.sandbox.sandbox.Sandbox.get_email_headers
async
Upload an email to receive headers
Parameters:
-
file(str | Path | bytes | BinaryIO) –path to .eml file or just binary data
Returns:
-
AsyncIterator[bytes]–The header file
Raises:
-
SandboxException–if the file type is not supported or the file cannot be opened
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
ptsandbox.sandbox.api._analysis.AnalysisMixin.get_email_headers
async
Upload an email to receive headers
Parameters:
-
data(BinaryIO) –file data
Returns:
-
AsyncIterator[bytes]–The header file
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors