Toolpal

@toolpal/email-send

public

v1.0published 1 download this weekMIT

Sends a plain-text or HTML email with optional file attachments via Resend (RESEND_API_KEY) or SMTP (SMTP_URL, supporting smtps:// and STARTTLS). Set EMAIL_FROM or pass `from` per call. Completes automated workflows alongside @toolpal/notify.

README.md1.1 KBRaw
# @toolpal/email-send

Sends plain-text or HTML emails with optional file attachments via **Resend** or **SMTP** (`smtps://` port 465 or `smtp://` port 587 with STARTTLS). Closes the delivery loop alongside `@toolpal/notify` for automated workflows.

## Setup

Configure **either** Resend or SMTP (you only need the variables for the provider you use):

| Provider | Environment Variables | Notes |
|---|---|---|
| Resend | `RESEND_API_KEY`, `EMAIL_FROM` | Uses `https://api.resend.com/emails`; sender domain must be verified in Resend |
| SMTP | `SMTP_URL`, `EMAIL_FROM` | e.g. `smtps://user:[email protected]:465` or `smtp://user:[email protected]:587` |

You can also pass `from` per call instead of setting `EMAIL_FROM`.

## Example

```json
{
  "to": ["[email protected]"],
  "subject": "Weekly expense report",
  "text": "Attached is this week's expense report.",
  "files": ["expense-report.xlsx"]
}
```

## Notes

- Supports up to 10 MB of total file attachments per email.
- Automatically upgrades plain `smtp://` connections with `STARTTLS` when advertised by the server.
- Blocks header injection (`CR`/`LF` in header fields).