Quick start

Install PostHog in up to three places:

  • Your server: the SDK sends email.
  • Your app: PostHog captures the events and people that broadcasts and automations use. If you already use PostHog for Product Analytics, this is done.
  • Your coding agent: the MCP builds your emails and reports how they did.

Send email from your server

Get an agent to do it

Run the wizard from your server project. It creates a project secret API key, installs the SDK, and adds the first send to your code.

Send your first email

npx @posthog/wizard email

Do it yourself

Send yourself an email in about a minute. You don't need to set up your domain first. Until you do, PostHog sends from the test sender, which only emails people in your PostHog organization.

  1. Go to Project secret API keys and click Create project secret API key. Set Transactional email to Write, and copy the key. It starts with phs_.
  2. Run this, with your key and the email address of your PostHog account. On EU Cloud, use https://eu.posthog.com.
Terminal
export POSTHOG_PROJECT_SECRET_API_KEY="phs_..."
curl -X POST "https://us.posthog.com/api/messaging/send/email/" \
-H "Authorization: Bearer $POSTHOG_PROJECT_SECRET_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"template_key": "hello-world",
"to": "you@example.com",
"subject": "Hello from PostHog",
"html": "<p>It works.</p>"
}'
  1. Check your inbox. To see the send in PostHog, open the Log tab.

Install an SDK

Or install the SDK yourself:

SDKSendsensitive and trackingcc, bcc, and attachments
Node.js5.62.05.71.05.72.0
Python7.84.07.89.07.91.0
GoAny v2, or 1.40.0 on v1Any v2, or 1.43.0Any v2, or 1.44.0
.NET2.20.02.24.02.25.0
RustAny posthog, or posthog-rs 0.31.0Any posthog, or 0.32.0Any posthog, or 0.33.0
Ruby3.30.03.33.03.34.0
Elixir2.20.02.21.02.22.0
PHP4.22.04.24.04.25.0

For another language, use the API. A send needs your secret API key, so send only from your server. The browser and mobile SDKs can't send email.

Capture events from your app

Install PostHog in your app or site. Its events can start an automation, such as a welcome email on signed_up. Its person properties choose who gets a broadcast. Identify each user and set their email person property, so PostHog knows where to send.

Platforms

Frameworks

Connect your agent

The PostHog MCP lets Claude Code, Cursor, Codex, and other agents write emails, build broadcasts and automations, move you off another provider, and report how each email did. Your agent saves its changes as drafts, and you publish them.

Install the PostHog MCP

npx @posthog/wizard mcp add

Still have questions?

Was this page useful?