# SendGrid.SmtpApi

**Kind:** Service

**Source:** `Pams/Core/Pams.Core/Pams.Core.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`SendGrid.SmtpApi` is a NuGet package dependency declared in `Pams.Core.csproj`. It supports SendGrid SMTP API header creation for email messages sent by the Pams.Core layer.

## Diagram

```mermaid
sequenceDiagram
    participant Application
    participant PamsCore as Pams.Core
    participant SmtpApi as SendGrid.SmtpApi
    participant SendGrid

    Application->>PamsCore: Request email delivery
    PamsCore->>SmtpApi: Create SMTP API headers
    SmtpApi-->>PamsCore: Return message headers
    PamsCore->>SendGrid: Send SMTP message with headers
    SendGrid-->>PamsCore: Return delivery response
```

## Usage

```ts
async function sendEmail() {
  const response = await fetch("/api/email/send", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      to: "recipient@example.com",
      subject: "Account update",
      text: "Your account has been updated.",
    }),
  });

  if (!response.ok) {
    throw new Error("Email delivery request failed.");
  }
}

void sendEmail();
```

## AI Coding Instructions

- Keep `SendGrid.SmtpApi` usage inside the server-side email delivery path; do not expose SMTP credentials or API headers to browser code.
- Add SendGrid SMTP API headers before sending the SMTP message.
- Preserve the NuGet package reference in `Pams.Core.csproj` when changing email-related code.
- Treat this dependency as legacy-format code and avoid replacing its message-header behavior without checking existing email integrations.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Injected or called by (1)

- `Pams.Core` — `Pams/Core/Pams.Core/Pams.Core.csproj`:1
