{"id":50580015,"url":"https://github.com/codewithmark/simple-sendy","last_synced_at":"2026-06-05T01:02:15.390Z","repository":{"id":299008762,"uuid":"76896016","full_name":"codewithmark/simple-sendy","owner":"codewithmark","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-16T04:01:26.000Z","size":33,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-16T18:43:03.464Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codewithmark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-12-19T20:46:35.000Z","updated_at":"2026-01-16T04:01:52.000Z","dependencies_parsed_at":"2025-06-14T05:43:33.791Z","dependency_job_id":null,"html_url":"https://github.com/codewithmark/simple-sendy","commit_stats":null,"previous_names":["codewithmark/simple-sendy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codewithmark/simple-sendy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmark%2Fsimple-sendy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmark%2Fsimple-sendy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmark%2Fsimple-sendy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmark%2Fsimple-sendy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codewithmark","download_url":"https://codeload.github.com/codewithmark/simple-sendy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmark%2Fsimple-sendy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33926275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-04T02:00:06.755Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-05T01:02:14.553Z","updated_at":"2026-06-05T01:02:15.378Z","avatar_url":"https://github.com/codewithmark.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimpleSendy\n\nA lightweight PHP wrapper for SendGrid's email API that simplifies sending transactional, broadcast, and multi-recipient emails with support for dynamic content, scheduling, and email tracking.\n\n## Features\n\n- 📧 **Transactional Emails** - Send personalized emails with dynamic data to individual recipients\n- 📢 **Broadcast Emails** - Send bulk emails to multiple subscribers with per-recipient customization\n- 👥 **Multi-Recipient Emails** - Send the same email to multiple recipients\n- 🕐 **Scheduled Delivery** - Schedule emails to be sent at a specific time\n- 📊 **Email Tracking** - Track opens and clicks with custom tracking IDs\n- 🏷️ **Categories** - Organize emails by category for better analytics\n- 🎯 **Dynamic Content** - Use placeholders like `{{user_name}}` for personalization\n- 🔧 **Custom Arguments** - Attach custom metadata to emails for tracking and reporting\n- ⏱️ **Timezone Support** - Handle different timezones for scheduled sends\n- 🚀 **Batching** - Automatically batch broadcast emails with random chunk sizes for better delivery\n\n## Requirements\n\n- PHP 7.4+\n- cURL extension\n- SendGrid API key\n\n## Installation\n\n1. Download `class_SimpleSendy_v3.php` to your project\n2. Include the class in your code:\n\n```php\nrequire_once 'class_SimpleSendy_v3.php';\n```\n\n3. Initialize with your SendGrid API key:\n\n```php\n$sendy = new SimpleSendy('your_sendgrid_api_key');\n```\n\n## Usage Examples\n\n### Basic Transactional Email\n\n```php\n$sendy = new SimpleSendy('your_sendgrid_api_key');\n\n$response = $sendy\n    -\u003efrom('Support', 'support@example.com')\n    -\u003ereplyTo('noreply@example.com')\n    -\u003esubject('Password Reset')\n    -\u003ebody('Hello {{user_name}}, reset link: {{reset_link}}')\n    -\u003etransactional('jane@example.com', [\n        'user_name' =\u003e 'Jane',\n        'reset_link' =\u003e 'https://example.com/reset?token=abc'\n    ])\n    -\u003esend();\n\nprint_r($response);\n```\n\n### Scheduled Transactional Email\n\n```php\n$sendy = new SimpleSendy('your_sendgrid_api_key');\n\n$response = $sendy\n    -\u003esetDefaultTimezone('America/New_York')\n    -\u003efrom('Support', 'support@example.com')\n    -\u003ereplyTo('noreply@example.com')\n    -\u003esubject('Scheduled Email for {{user_name}}')\n    -\u003ebody('\u003cp\u003eHello {{user_name}}, your report is ready.\u003c/p\u003e')\n    -\u003esendAt('2025-07-05 09:00:00')\n    -\u003etransactional('alice@example.com', [\n        'user_name' =\u003e 'Alice',\n        'user_id' =\u003e 123,\n        'plan' =\u003e 'pro'\n    ])\n    -\u003etransactional('jane@example.com', ['user_name' =\u003e 'Jane'])\n    -\u003esend();\n```\n\n### Multi-Recipient Email\n\n```php\n$sendy = new SimpleSendy('your_sendgrid_api_key');\n\n$recipients = [\n    'alice@example.com',\n    'bob@example.com',\n    'carol@example.com'\n];\n\n$response = $sendy\n    -\u003efrom('MyApp Team', 'newsletter@myapp.com')\n    -\u003ereplyTo('support@myapp.com')\n    -\u003esubject('Important Update')\n    -\u003ebody('\u003cp\u003eWe have an important announcement for you.\u003c/p\u003e')\n    -\u003eemails($recipients)\n    -\u003esend();\n```\n\n### Broadcast Email (One-to-Many with Personalization)\n\n```php\n$sendy = new SimpleSendy('your_sendgrid_api_key');\n\n$subscribers = [\n    ['email' =\u003e 'alice@example.com', 'user_name' =\u003e 'Alice', 'user_id' =\u003e 101],\n    ['email' =\u003e 'bob@example.com', 'user_name' =\u003e 'Bob', 'user_id' =\u003e 102],\n    ['email' =\u003e 'carol@example.com', 'user_name' =\u003e 'Carol', 'user_id' =\u003e 103],\n];\n\n$tracking_id = 'TrackingId_' . uniqid();\n$category_id = 'newsletter_' . uniqid();\n\n$response = $sendy\n    -\u003esetDefaultTimezone('America/New_York')\n    -\u003esetCategory($category_id)\n    -\u003esetTrackingId($tracking_id)\n    -\u003efrom('MyApp Team', 'newsletter@myapp.com')\n    -\u003ereplyTo('support@myapp.com')\n    -\u003esubject('Hello {{user_name}}, check out what\\'s new!')\n    -\u003ebody('\u003cp\u003eHi {{user_name}},\u003c/p\u003e\u003cp\u003eHere\\'s our latest news!\u003c/p\u003e')\n    -\u003etrack(true, true)  // Enable open and click tracking\n    -\u003esendAt('2025-07-06 09:00:00')\n    -\u003ebroadcast($subscribers, ['user_name'], ['user_name' =\u003e 'Subscriber'])\n    -\u003esend();\n\nprint_r($response);\n```\n\n### With Custom Tracking and Categories\n\n```php\n$sendy = new SimpleSendy('your_sendgrid_api_key');\n\n$response = $sendy\n    -\u003efrom('Support', 'support@example.com')\n    -\u003ereplyTo('noreply@example.com')\n    -\u003esubject('Welcome {{first_name}}!')\n    -\u003ebody('\u003cp\u003eWelcome to our platform, {{first_name}}!\u003c/p\u003e')\n    -\u003esetCategory('welcome_emails')\n    -\u003esetTrackingId('welcome_' . time())\n    -\u003etransactional('newuser@example.com', ['first_name' =\u003e 'John'])\n    -\u003esend();\n```\n\n## API Reference\n\n### Configuration Methods\n\n#### `__construct(string $apiKey)`\nInitialize the SimpleSendy instance with your SendGrid API key.\n\n#### `setDefaultTimezone(string $timezone): self`\nSet the default timezone for scheduled sends. Pass a valid PHP timezone identifier (e.g., 'America/New_York').\n\n#### `setCategory(string $category): self`\nAssign a category to the email for analytics and organization.\n\n#### `setTrackingId(string $id = ''): self`\nSet a custom tracking ID. If empty, one is auto-generated. Use this to correlate emails with user actions.\n\n#### `setCustomArgs(array $customArgs): self`\nAttach custom metadata to emails for tracking and reporting.\n\n### Sender Methods\n\n#### `from(string $name, string $email): self`\nSet the sender's name and email address.\n\n#### `replyTo(string $email): self`\nSet the reply-to email address.\n\n#### `subject(string $subject): self`\nSet the email subject. Supports placeholders like `{{variable_name}}`.\n\n#### `body(string $content): self`\nSet the email body content. Automatically detects HTML vs. plain text.\n\n### Tracking Methods\n\n#### `track(bool $opens = true, bool $clicks = true): self`\nEnable/disable open and click tracking.\n\n### Scheduling Methods\n\n#### `sendAt(string $datetime): self`\nSchedule the email to be sent at a specific time (must be in the future).\n- Respects the timezone set via `setDefaultTimezone()`\n- Throws `InvalidArgumentException` if the time is in the past\n\n### Recipient Methods\n\n#### `transactional(string $email, array $dynamicData = []): self`\nSend a personalized email to a single recipient. Each call adds another recipient to the batch.\n- `$email`: Recipient email address\n- `$dynamicData`: Key-value pairs for placeholder replacement\n\n#### `emails(array $emailList): self`\nSend the same email to multiple recipients at once.\n- Accepts an array of email strings or email objects\n\n#### `broadcast(array $subscribers, array $dynamicKeys = [], array $fallbacks = []): self`\nSend personalized emails to multiple subscribers.\n- `$subscribers`: Array of subscriber objects with email and other properties\n- `$dynamicKeys`: Array of keys to extract from each subscriber for personalization\n- `$fallbacks`: Default values if a key is missing in a subscriber\n\n### Send Method\n\n#### `send(): array`\nSend all queued emails and return an array of responses. Each response contains:\n```php\n[\n    'status' =\u003e 'success' | 'error',\n    'code' =\u003e HTTP_STATUS_CODE,\n    'message' =\u003e 'Error message (if applicable)',\n    'response' =\u003e array // SendGrid API response (if applicable)\n]\n```\n\n## Response Format\n\nSuccessful response:\n```php\n['status' =\u003e 'success', 'code' =\u003e 202]\n```\n\nError response:\n```php\n['status' =\u003e 'error', 'message' =\u003e 'cURL error message']\n// or\n['status' =\u003e 'error', 'code' =\u003e 400, 'response' =\u003e [...SendGrid API error...]]\n```\n\n## Tips \u0026 Best Practices\n\n1. **Placeholders**: Use double curly braces `{{key_name}}` in your subject and body for dynamic content\n2. **Batch Sends**: Broadcast emails are automatically chunked with random sizes (800-950) to avoid SendGrid rate limits, with 5-second delays between batches\n3. **Tracking IDs**: Use custom tracking IDs to correlate emails with user actions for analytics\n4. **Fallbacks**: When using broadcast, provide fallback values for missing dynamic keys\n5. **Error Handling**: Always check the response status to handle failures\n\n## Error Handling\n\n```php\n$responses = $sendy\n    -\u003efrom('Support', 'support@example.com')\n    -\u003esubject('Test Email')\n    -\u003ebody('Test content')\n    -\u003etransactional('user@example.com', [])\n    -\u003esend();\n\nforeach ($responses as $response) {\n    if ($response['status'] === 'error') {\n        echo \"Error: \" . $response['message'];\n    } else {\n        echo \"Email sent successfully!\";\n    }\n}\n```\n\n## License\n\nMIT License - Feel free to use this in your projects!\n\n## Support\n\nFor issues or questions, please refer to the SendGrid API documentation at https://docs.sendgrid.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodewithmark%2Fsimple-sendy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodewithmark%2Fsimple-sendy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodewithmark%2Fsimple-sendy/lists"}