You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$email = new CakeEmail(array('from' => 'me@example.org', 'transport' => 'MyCustom'));
102
+
80
103
You can configure SSL SMTP servers, like GMail. To do so, put the ``'ssl://'``
81
104
at prefix in the host and configure the port value accordingly. Example::
82
105
@@ -95,6 +118,40 @@ at prefix in the host and configure the port value accordingly. Example::
95
118
To use this feature, you will need to have the SSL configured in your PHP
96
119
install.
97
120
121
+
.. _email-configurations:
122
+
123
+
Configurations
124
+
--------------
125
+
126
+
The following configuration keys are used:
127
+
128
+
- ``'from'``: Email or array of sender. See ``CakeEmail::from()``.
129
+
- ``'sender'``: Email or array of real sender. See ``CakeEmail::sender()``.
130
+
- ``'to'``: Email or array of destination. See ``CakeEmail::to()``.
131
+
- ``'cc'``: Email or array of carbon copy. See ``CakeEmail::cc()``.
132
+
- ``'bcc'``: Email or array of blind carbon copy. See ``CakeEmail::bcc()``.
133
+
- ``'replyTo'``: Email or array to reply the e-mail. See ``CakeEmail::replyTo()``.
134
+
- ``'readReceipt'``: Email or array to receive the receipt of read. See ``CakeEmail::readReceipt()``.
135
+
- ``'returnPath'``: Email or array to return if have some error. See ``CakeEmail::returnPath()``.
136
+
- ``'messageId'``: Message ID of e-mail. See ``CakeEmail::messageId()``.
137
+
- ``'subject'``: Subject of the message. See ``CakeEmail::subject()``.
138
+
- ``'message'``: Content of message. Do not set this field if you are using rendered content.
139
+
- ``'headers'``: Headers to be included. See ``CakeEmail::setHeaders()``.
140
+
- ``'viewRender'``: If you are using rendered content, set the view classname. See ``CakeEmail::viewRender()``.
141
+
- ``'template'``: If you are using rendered content, set the template name. See ``CakeEmail::template()``.
142
+
- ``'layout'``: If you are using rendered content, set the layout to render. If you want to render a template without layout, set this field to null. See ``CakeEmail::template()``.
143
+
- ``'viewVars'``: If you are using rendered content, set the array with variables to be used in the view. See ``CakeEmail::viewVars()``.
144
+
- ``'attachments'``: List of files to attach. See ``CakeEmail::attachments()``.
145
+
- ``'emailFormat'``: Format of email (html, text or both). See ``CakeEmail::emailFormat()``.
146
+
- ``'transport'``: Transport name. See ``CakeEmail::transport()``.
147
+
- ``'log'``: Log level to log the email headers and message. ``true`` will use LOG_DEBUG. See also ``CakeLog::write()``
148
+
149
+
All these configurations are optional, except ``'from'``. If you put more
150
+
configuration in this array, the configurations will be used in the
151
+
:php:meth:`CakeEmail::config()` method and passed to the transport class ``config()``.
152
+
For example, if you are using smtp transport, you should pass the host, port and
153
+
other configurations.
154
+
98
155
Setting headers
99
156
---------------
100
157
@@ -142,6 +199,16 @@ This would use the following view files:
142
199
When sending templated emails you have the option of sending either
143
200
``text``, ``html`` or ``both``.
144
201
202
+
You can set view variables with ``CakeEmail::viewVars()``::
203
+
204
+
<?php
205
+
$email = new CakeEmail('templated');
206
+
$email->viewVars(array('value' => 12345));
207
+
208
+
And in your email templates you can use these with::
209
+
210
+
<p>Here is your value: <b><?php echo $value; ?></b></p>
211
+
145
212
Sending attachments
146
213
-------------------
147
214
@@ -158,15 +225,15 @@ you want the filenames to appear in the recipient's mail client:
158
225
attach some_hash.png with the name photo.png. The recipient will see
159
226
photo.png, not some_hash.png.
160
227
4. Nested arrays::
161
-
162
-
<?php
163
-
$email->attachments(array(
164
-
'photo.png' => array(
165
-
'file' => '/full/some_hash.png',
166
-
'mimetype' => 'image/png',
167
-
'contentId' => 'my-unique-id'
168
-
)
169
-
));
228
+
229
+
<?php
230
+
$email->attachments(array(
231
+
'photo.png' => array(
232
+
'file' => '/full/some_hash.png',
233
+
'mimetype' => 'image/png',
234
+
'contentId' => 'my-unique-id'
235
+
)
236
+
));
170
237
171
238
The above will attach the file with different mimetype and with custom
172
239
Content ID (when set the content ID the attachment is transformed to inline).
@@ -182,7 +249,7 @@ Transports are classes designed to send the e-mail over some protocol or method.
182
249
CakePHP support the Mail (default), Debug and Smtp transports.
183
250
184
251
To configure your method, you must use the :php:meth:`CakeEmail::transport()`
185
-
method.
252
+
method or have the transport in your configuration
186
253
187
254
Creating custom Transports
188
255
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -222,8 +289,8 @@ Sending messages quickly
222
289
========================
223
290
224
291
Sometimes you need a quick way to fire off an email, and you don't necessarily
225
-
want do setup a bunch of configuration ahead of time.
226
-
:php:meth:`~CakeEmail::deliver()` is intended for that purpose.
292
+
want do setup a bunch of configuration ahead of time.
293
+
:php:meth:`CakeEmail::deliver()` is intended for that purpose.
227
294
228
295
You can create your configuration in ``EmailConfig``, or use an array with all
229
296
options that you need and use the static method ``CakeEmail::deliver()``.
@@ -247,30 +314,5 @@ The 4th parameter can be an array with the configurations or a string with the
247
314
name of configuration in ``EmailConfig``.
248
315
249
316
If you want, you can pass the to, subject and message as null and do all
250
-
configurations in the 4th parameter (as array or using ``EmailConfig``). The
251
-
follow configurations are used:
252
-
253
-
- ``'from'``: Email or array of sender. See ``CakeEmail::from()``.
254
-
- ``'sender'``: Email or array of real sender. See ``CakeEmail::sender()``.
255
-
- ``'to'``: Email or array of destination. See ``CakeEmail::to()``.
256
-
- ``'cc'``: Email or array of carbon copy. See ``CakeEmail::cc()``.
257
-
- ``'bcc'``: Email or array of blind carbon copy. See ``CakeEmail::bcc()``.
258
-
- ``'replyTo'``: Email or array to reply the e-mail. See ``CakeEmail::replyTo()``.
259
-
- ``'readReceipt'``: Email or array to receive the receipt of read. See ``CakeEmail::readReceipt()``.
260
-
- ``'returnPath'``: Email or array to return if have some error. See ``CakeEmail::returnPath()``.
261
-
- ``'messageId'``: Message ID of e-mail. See ``CakeEmail::messageId()``.
262
-
- ``'subject'``: Subject of the message. See ``CakeEmail::subject()``.
263
-
- ``'message'``: Content of message. Do not set this field if you are using rendered content.
264
-
- ``'headers'``: Headers to be included. See ``CakeEmail::setHeaders()``.
265
-
- ``'viewRender'``: If you are using rendered content, set the view classname. See ``CakeEmail::viewRender()``.
266
-
- ``'template'``: If you are using rendered content, set the template name. See ``CakeEmail::template()``.
267
-
- ``'layout'``: If you are using rendered content, set the layout to render. If you want to render a template without layout, set this field to null. See ``CakeEmail::template()``.
268
-
- ``'viewVars'``: If you are using rendered content, set the array with variables to be used in the view. See ``CakeEmail::viewVars()``.
269
-
- ``'attachments'``: List of files to attach. See ``CakeEmail::attachments()``.
270
-
- ``'emailFormat'``: Format of email (html, text or both). See ``CakeEmail::emailFormat()``.
271
-
- ``'transport'``: Transport name. See ``CakeEmail::transport()``.
272
-
273
-
All these configurations are optional, except ``'from'``. If you put more
274
-
configuration in this array, the configurations will be used in the
275
-
:php:meth:`CakeEmail::config()` method. For example, if you are using smtp transport,
276
-
you should pass the host, port and others configurations.
317
+
configurations in the 4th parameter (as array or using ``EmailConfig``).
318
+
Check the list of :ref:`configurations <email-configurations>` to see all accepted configs.
0 commit comments