# Test Skills

> Send Email Skill

- Skill: `bagalobsta/test-skills` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add bagalobsta/test-skills`
- Raw SKILL.md: https://api.skillmd.com/api/skills/bagalobsta/test-skills/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- Author: bagalobsta (https://skillmd.com/u/bagalobsta)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/bagalobsta/test-skills

---

# Send Email Skill

## Overview

This skill allows you to send emails through an SMTP server. It handles authentication, attachment support, and error handling with proper logging.

## Parameters

- **to** (string, required): Email address of the recipient
- **subject** (string, required): Email subject line
- **body** (string, required): Email body content (supports HTML)
- **from** (string, optional): Sender email address (defaults to configured address)
- **attachments** (array, optional): Array of file paths to attach
- **cc** (array, optional): CC recipients
- **bcc** (array, optional): BCC recipients

## Returns

- **success** (boolean): Whether the email was sent successfully
- **messageId** (string): Unique message identifier for tracking
- **timestamp** (ISO 8601): When the email was sent

## Examples

### Basic Usage

```javascript
const result = await emailSkill.send({
  to: 'user@example.com',
  subject: 'Hello!',
  body: 'This is a test email.'
});

console.log(`Email sent with ID: ${result.messageId}`);
```

### With Attachments

```javascript
const result = await emailSkill.send({
  to: 'user@example.com',
  subject: 'Report',
  body: 'Please find the report attached.',
  attachments: ['/path/to/report.pdf']
});
```

### Error Handling

```javascript
try {
  const result = await emailSkill.send({
    to: 'invalid-email',
    subject: 'Test',
    body: 'Content'
  });
} catch (error) {
  if (error.code === 'INVALID_EMAIL') {
    console.error('Invalid email address provided');
  } else if (error.code === 'AUTH_FAILED') {
    console.error('SMTP authentication failed - check credentials');
  } else {
    console.error(`Unexpected error: ${error.message}`);
  }
}
```

## Permissions Required

- **email:send** - Required to send emails
- **filesystem:read** - Required for accessing attachments
- **credential:smtp** - Requires SMTP server configuration

⚠️ **Warning:** This skill requires SMTP credentials to be configured securely. Never hardcode credentials in your skill definitions. Use environment variables or secure credential storage.

## Error Handling

The skill can throw the following errors:

- `INVALID_EMAIL` - Recipient email format is invalid
- `AUTH_FAILED` - SMTP authentication failed
- `ATTACHMENT_NOT_FOUND` - Referenced attachment file doesn't exist
- `SIZE_LIMIT_EXCEEDED` - Email size exceeds server limits
- `NETWORK_ERROR` - Connection to SMTP server failed

All errors are logged with context and timestamps for debugging.

## Input Validation

- Email addresses are validated against RFC 5322 standard
- Attachment paths are checked for existence and readability
- Email body size is limited to 25MB
- HTML content is sanitized to prevent injection attacks

## Best Practices

1. **Always validate email addresses** before sending
2. **Use try-catch blocks** around email operations
3. **Store credentials securely** - use env vars or secret management
4. **Implement rate limiting** to prevent spam
5. **Log successful sends** for audit trails
6. **Test with test@example.com** before production use

## Related Skills

- [sendSMS](./send-sms.md) - Send SMS messages
- [sendSlack](./send-slack.md) - Send Slack notifications
- [sendWebhook](./send-webhook.md) - Send HTTP webhooks

## Support

For issues or questions, see [Email Skill Documentation](https://docs.example.com/skills/email)

