Skill: manifoldor/mailgun (version 1.0.6)

--- name: mailgun description: Send emails via Mailgun API. Use when the user needs to send emails programmatically, such as newsletters, notifications, alerts, or automated reports. Requires MAILGUN_API_KEY and MAILGUN_DOMAIN environment variables to be configured. env: - MAILGUN_API_KEY - MAILGUN_DOMAIN - MAILGUN_FROM - MAILGUN_DEFAULT_TO homepage: https://github.com/openclaw/openclaw repository: https://github.com/openclaw/openclaw --- # Mailgun Email Sender Send emails programmatically using Mailgun's HTTP API. ## Prerequisites Configure the following environment variables in `~/.zshrc` or `~/.bash_profile`: ```bash export MAILGUN_API_KEY="key-xxxxx" # Your Mailgun private API key export MAILGUN_DOMAIN="mg.yourdomain.com" # Your Mailgun domain export MAILGUN_FROM="Sender <[REDACTED_SECRET]>" # Default sender export MAILGUN_DEFAULT_TO="[REDACTED_SECRET]" # Default recipient (optional) ``` Then reload your shell configuration: ```bash source ~/.zshrc ``` ## Usage ### Send a simple email ```bash mailgun/scripts/send_email.sh "Subject" "Email body text" ``` ### Send to a specific recipient ```bash mailgun/scripts/send_email.sh "Newsletter" "Content here" "[REDACTED_SECRET]" ``` ### Send with custom sender ```bash mailgun/scripts/send_email.sh "Alert" "System down" "[REDACTED_SECRET]" "[REDACTED_SECRET]" ``` ## Features - Simple command-line interface - Uses environment variables for configuration - Supports custom sender and recipient - Returns success/error status codes - Works with HTML content (pass HTML in body parameter) ## Common Use Cases - Daily/weekly newsletters - System alerts and notifications - Automated reports - Confirmation emails - Scheduled reminders ## Troubleshooting **Error: MAILGUN_API_KEY and MAILGUN_DOMAIN must be set** → Configure environment variables as shown in Prerequisites **Error: 401 Unauthorized** → Check that your API key is correct and active **Error: 404 Not Found** → Verify your MAILGUN_DOMAIN is correct ## References - Mailgun Documentation: https://documentation.mailgun.com/ - API Reference: See [references/api.md](references/api.md)

path: scripts/send_email.sh
content: #!/bin/bash

# Mailgun 邮件发送脚本
# Usage: send_email.sh <subject> <body> [to_email] [from_email]

# 如果环境变量未设置，尝试从配置文件读取
if [ -z "$MAILGUN_API_KEY" ] && [ -f ~/.config/mailgun/credentials ]; then
    source ~/.config/mailgun/credentials
fi

SUBJECT="$1"
BODY="$2"
TO="${3:-$MAILGUN_DEFAULT_TO}"
FROM="${4:-$MAILGUN_FROM}"

if [ -z "$SUBJECT" ] || [ -z "$BODY" ]; then
    echo "Error: Subject and body are required"
    echo "Usage: $0 \"Subject\" \"Body\" [[REDACTED_SECRET]] [[REDACTED_SECRET]]"
    exit 1
fi

if [ -z "$MAILGUN_API_KEY" ] || [ -z "$MAILGUN_DOMAIN" ]; then
    echo "Error: MAILGUN_API_KEY and MAILGUN_DOMAIN must be set"
    echo "Please configure in ~/.config/mailgun/credentials"
    exit 1
fi

# Send email via Mailgun API
RESPONSE=$(curl -s -w "\n%{http_code}" --user "api:$MAILGUN_API_KEY" \
    "https://api.mailgun.net/v3/$MAILGUN_DOMAIN/messages" \
    -F from="$FROM" \
    -F to="$TO" \
    -F subject="$SUBJECT" \
    -F text="$BODY")

HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d')

if [ "$HTTP_CODE" = "200" ]; then
    echo "✅ Email sent successfully to $TO"
    echo "Response: $BODY"
    exit 0
else
    echo "❌ Failed to send email (HTTP $HTTP_CODE)"
    echo "Response: $BODY"
    exit 1
fi


path: references/api.md
content: # Mailgun API Reference

## Authentication

All API requests use HTTP Basic Authentication with the API key as the username.

```
Authorization: Basic api:YOUR_API_KEY
```

## Endpoints

### Send Message

**URL**: `POST https://api.mailgun.net/v3/{domain}/messages`

**Parameters**:
- `from` (required): Sender email address
- `to` (required): Recipient email address
- `subject` (required): Email subject
- `text` (optional): Plain text body
- `html` (optional): HTML body
- `cc` (optional): CC recipients
- `bcc` (optional): BCC recipients
- `attachment` (optional): File attachments

**Example Response (200)**:
```json
{
  "id": "<[REDACTED_SECRET]>",
  "message": "Queued. Thank you."
}
```

## Rate Limits

Free tier: 100 emails/hour
Paid tiers: Higher limits based on plan

## Pricing

- Free: 5,000 emails/month for 3 months, then 1,000/month
- Foundation: $15/month for 10,000 emails
- Growth: $65/month for 50,000 emails

See https://www.mailgun.com/pricing/ for current rates.


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: clean (LOW)