57 lines
1.1 KiB
Plaintext
57 lines
1.1 KiB
Plaintext
---
|
|
title: Send Your First Email
|
|
description: Send a transactional email in 5 minutes
|
|
icon: Mail
|
|
---
|
|
|
|
## 1. Get your API key
|
|
|
|
1. Go to **Settings → General**
|
|
2. Copy your **Secret Key** (starts with `sk_`)
|
|
|
|
## 2. Send the email
|
|
|
|
```bash
|
|
curl -X POST {{API_URL}}/v1/send \
|
|
-H "Authorization: Bearer sk_your_secret_key" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"to": "user@example.com",
|
|
"subject": "Hello from Plunk",
|
|
"body": "<p>Your first email!</p>"
|
|
}'
|
|
```
|
|
|
|
## 3. With variables
|
|
|
|
```javascript
|
|
await fetch('{{API_URL}}/v1/send', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Authorization': `Bearer ${process.env.PLUNK_SECRET_KEY}`,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
to: user.email,
|
|
subject: 'Reset your password',
|
|
body: '<p>Hi {{name}}, click here: <a href="{{resetLink}}">Reset</a></p>',
|
|
name: user.name,
|
|
resetLink: `https://app.com/reset/${token}`
|
|
})
|
|
});
|
|
```
|
|
|
|
## 4. Using a template
|
|
|
|
1. Create template in **Templates → Create Template**
|
|
2. Send using template ID:
|
|
|
|
```javascript
|
|
{
|
|
to: user.email,
|
|
template: 'clx123abc456',
|
|
name: user.name,
|
|
resetLink: resetUrl
|
|
}
|
|
```
|