{"id":25899052,"url":"https://github.com/sprintcube/cakephp-elastic-email","last_synced_at":"2025-03-03T01:19:54.113Z","repository":{"id":57043170,"uuid":"138294661","full_name":"sprintcube/cakephp-elastic-email","owner":"sprintcube","description":"Elastic Email plugin for CakePHP 3","archived":false,"fork":false,"pushed_at":"2018-09-24T12:14:40.000Z","size":30,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-29T20:09:42.096Z","etag":null,"topics":["cakephp","cakephp-plugin","elasticemail","email","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sprintcube.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-22T11:25:47.000Z","updated_at":"2018-09-24T12:14:41.000Z","dependencies_parsed_at":"2022-08-24T01:21:05.557Z","dependency_job_id":null,"html_url":"https://github.com/sprintcube/cakephp-elastic-email","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sprintcube%2Fcakephp-elastic-email","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sprintcube%2Fcakephp-elastic-email/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sprintcube%2Fcakephp-elastic-email/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sprintcube%2Fcakephp-elastic-email/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sprintcube","download_url":"https://codeload.github.com/sprintcube/cakephp-elastic-email/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241592608,"owners_count":19987393,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cakephp","cakephp-plugin","elasticemail","email","php"],"created_at":"2025-03-03T01:19:53.367Z","updated_at":"2025-03-03T01:19:54.103Z","avatar_url":"https://github.com/sprintcube.png","language":"PHP","readme":"# Elastic Email Plugin for CakePHP 3\n\n[![Build Status](https://travis-ci.org/sprintcube/cakephp-elastic-email.svg?branch=master)](https://travis-ci.org/sprintcube/cakephp-elastic-email)\n[![codecov](https://codecov.io/gh/sprintcube/cakephp-elastic-email/branch/master/graph/badge.svg)](https://codecov.io/gh/sprintcube/cakephp-elastic-email)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Latest Stable Version](https://poser.pugx.org/sprintcube/cakephp-elastic-email/v/stable)](https://packagist.org/packages/sprintcube/cakephp-elastic-email)\n[![Total Downloads](https://poser.pugx.org/sprintcube/cakephp-elastic-email/downloads)](https://packagist.org/packages/sprintcube/cakephp-elastic-email)\n\nThis plugin provides email delivery using [Elastic Email](https://elasticemail.com/).\n\n## Requirements\n\nThis plugin has the following requirements:\n\n* CakePHP 3.4.0 or greater.\n* PHP 5.6 or greater.\n\n## Installation\n\nYou can install this plugin into your CakePHP application using [composer](http://getcomposer.org).\n\n```\ncomposer require sprintcube/cakephp-elastic-email\n```\n\nAfter installation, [Load the plugin](http://book.cakephp.org/3.0/en/plugins.html#loading-a-plugin)\n```php\nPlugin::load('ElasticEmail');\n```\nOr, you can load the plugin using the shell command\n```sh\n$ bin/cake plugin load ElasticEmail\n```\n\n## Setup\n\nSet your Elastic Email Api key in `EmailTransport` settings in app.php\n\n```php\n'EmailTransport' =\u003e [\n...\n  'elasticemail' =\u003e [\n      'className' =\u003e 'ElasticEmail.ElasticEmail',\n      'apiKey' =\u003e 'your-api-key' // your api key\n  ]\n]\n```\n\nIf you face an SSL certificate error, please follow below steps:\n\n1. Open http://curl.haxx.se/ca/cacert.pem  \n2. Copy the entire page and save it as a \"cacert.pem\"  \n3. Open your php.ini file and insert or update the following line: curl.cainfo = \"[pathtofile]\\cacert.pem\"\n\nAnd create new delivery profile in `Email` settings.\n\n```php\n'Email' =\u003e [\n    'default' =\u003e [\n        'transport' =\u003e 'default',\n        'from' =\u003e 'you@localhost',\n        //'charset' =\u003e 'utf-8',\n        //'headerCharset' =\u003e 'utf-8',\n    ],\n    'elasticemail' =\u003e [\n        'transport' =\u003e 'elasticemail'\n    ]\n]\n```\n\n## Usage\n\nYou can now simply use the CakePHP `Email` to send an email via Elastic Email.\n\n```php\n$email = new Email('elasticemail');\n        \n$email-\u003esetFrom(['you@yourdomain.com' =\u003e 'CakePHP Elastic Email'])\n    -\u003esetSender('someone@example.com', 'Someone')\n    -\u003esetTo('foo@example.com.com')\n    -\u003eaddTo('bar@example.com')\n    -\u003esetHeaders(['X-Custom' =\u003e 'headervalue'])\n    -\u003esetSubject('Email from CakePHP Elastic Email plugin')\n    -\u003esend('Message from CakePHP Elastic Email plugin');\n```\n\nThat is it.\n\n## Advance Use\nYou can also use few more options to send email via Elastic Email APIs. To do so, get the transport instance and call the appropriate methods before sending the email.\n\n### Transactional Email\nYou can mark the email as `transactional` email.\n\n```php\n$email = new Email('elasticemail');\n$emailInstance = $email-\u003egetTransport();\n$emailInstance-\u003eisTransactional(true);\n$email-\u003esend();\n```\n\n### Custom Headers\nYou can pass your own headers. It must be prefixed with \"X-\". Use the default `Email::setHeaders` method like,\n\n```php\n$email = new Email('elasticemail');\n        \n$email-\u003esetFrom(['you@yourdomain.com' =\u003e 'CakePHP Elastic Email'])\n    -\u003esetSender('someone@example.com', 'Someone')\n    -\u003esetTo('foo@example.com.com')\n    -\u003eaddTo('bar@example.com')\n    -\u003esetHeaders([\n        'X-Custom' =\u003e 'headervalue',\n        'X-MyHeader' =\u003e 'myvalue'\n    ])\n    -\u003esetSubject('Email from CakePHP Elastic Email plugin')\n    -\u003esend('Message from CakePHP Elastic Email plugin');\n```\n\n\u003e Make sure you have enabled custom header from your Elastic Email settings.\n\n### Attachments\nSet your attachments using `Email::setAttachments` method.\n\n```php\n$email = new Email('elasticemail');\n        \n$email-\u003esetFrom(['you@yourdomain.com' =\u003e 'CakePHP Elastic Email'])\n    -\u003esetSender('someone@example.com', 'Someone')\n    -\u003esetTo('foo@example.com.com')\n    -\u003eaddTo('bar@example.com')\n    -\u003esetAttachments([\n        'cake_icon1.png' =\u003e Configure::read('App.imageBaseUrl') . 'cake.icon.png',\n        'cake_icon2.png' =\u003e ['file' =\u003e Configure::read('App.imageBaseUrl') . 'cake.icon.png'],\n        WWW_ROOT . 'favicon.ico'\n    ])\n    -\u003esetSubject('Email from CakePHP Elastic Email plugin')\n    -\u003esend('Message from CakePHP Elastic Email plugin');\n```\n\n\u003e You need to have some credit in your account to send attachments. Otherwise you will get `Not enough credit for campaign.` error.\n\n### Template\nYou can use the template created in Elastic Email backend. Get the template id by either using their API or from the URL.\nSet the template id using `setTemplate` method.\n\n```php\n$email = new Email('elasticemail');\n$emailInstance = $email-\u003egetTransport();\n$emailInstance-\u003esetTemplte(123);\n$email-\u003esend();\n```\n\n### Template Variables\nElastic Email provides a nice way to replace the template content using template variables. You can use variables like {firstname}, {lastname} in your template and pass their replacement value.\n\n```php\n$mergeVars = [\n    'firstname' =\u003e 'Foo',\n    'lastname' =\u003e 'Bar',\n    'title' =\u003e 'Good Title'\n];\n\n$email = new Email('elasticemail');\n$emailInstance = $email-\u003egetTransport();\n$emailInstance-\u003esetMergeVariables($mergeVars);\n\n$email-\u003esetFrom(['from@example.com' =\u003e 'CakePHP Elastic Email'])\n    -\u003esetTo('to@example.com')\n    -\u003esetEmailFormat('both')\n    -\u003esetSubject('{title} - Email from CakePHP Elastic Email plugin')\n    -\u003esend('Hello {firstname} {lastname}, \u003cbr\u003e This is an email from CakePHP Elastic Email plugin.');\n```\n\n### Schedule\nYou can schedule the email to be sent in future date. You can set upto 1 year in future i.e. 524160 minutes.\n\n```php\n$email = new Email('elasticemail');\n$emailInstance = $email-\u003egetTransport();\n$emailInstance-\u003esetScheduleTime(60); // after 1 hour from sending time\n$email-\u003esend();\n```\n\n## Reporting Issues\n\nIf you have a problem with this plugin or any bug, please open an issue on [GitHub](https://github.com/sprintcube/cakephp-elastic-email/issues).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsprintcube%2Fcakephp-elastic-email","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsprintcube%2Fcakephp-elastic-email","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsprintcube%2Fcakephp-elastic-email/lists"}