Skip to content

Commit 2807aca

Browse files
Update doc
1 parent df620e0 commit 2807aca

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ That is it.
9090
You 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.
9191

9292
### Transactional Email
93-
You can mark the email as `transaction` email.
93+
You can mark the email as `transactional` email.
9494

9595
```php
9696
$email = new Email('elasticemail');
@@ -99,6 +99,47 @@ $emailInstance->isTransactional(true);
9999
$email->send();
100100
```
101101

102+
### Custom Headers
103+
You can pass your own headers. It must be prefixed with "X-". Use the default `Email::setHeaders` method like,
104+
105+
```php
106+
$email = new Email('elasticemail');
107+
108+
$email->setFrom(['you@yourdomain.com' => 'CakePHP Elastic Email'])
109+
->setSender('someone@example.com', 'Someone')
110+
->setTo('foo@example.com.com')
111+
->addTo('bar@example.com')
112+
->setHeaders([
113+
'X-Custom' => 'headervalue',
114+
'X-MyHeader' => 'myvalue'
115+
])
116+
->setSubject('Email from CakePHP Elastic Email plugin')
117+
->send('Message from CakePHP Elastic Email plugin');
118+
```
119+
120+
> Make sure you have enabled custom header from your Elastic Email settings.
121+
122+
### Attachments
123+
Set your attachments using `Email::setAttachments` method.
124+
125+
```php
126+
$email = new Email('elasticemail');
127+
128+
$email->setFrom(['you@yourdomain.com' => 'CakePHP Elastic Email'])
129+
->setSender('someone@example.com', 'Someone')
130+
->setTo('foo@example.com.com')
131+
->addTo('bar@example.com')
132+
->setAttachments([
133+
'cake_icon1.png' => Configure::read('App.imageBaseUrl') . 'cake.icon.png',
134+
'cake_icon2.png' => ['file' => Configure::read('App.imageBaseUrl') . 'cake.icon.png'],
135+
WWW_ROOT . 'favicon.ico'
136+
])
137+
->setSubject('Email from CakePHP Elastic Email plugin')
138+
->send('Message from CakePHP Elastic Email plugin');
139+
```
140+
141+
> You need to have some credit in your account to send attachments. Otherwise you will get `Not enough credit for campaign.` error.
142+
102143
### Template
103144
You can use the template created in Elastic Email backend. Get the template id by either using their API or from the URL.
104145
Set the template id using `setTemplate` method.

0 commit comments

Comments
 (0)