CakePHP
CakePHP comes with an email library that already supports SMTP. For more information check out the CakePHP documentation page. This example shows how to send an email with both HTML and text bodies.
In app/views/layouts/ you need to define the layout of your text and HTML emails:
1 2 3 4 5 |
|
In app/views/layouts/email/text/default.ctp add:
1
|
|
and in app/views/layouts/email/html/default.ctp add:
1
|
|
Then create the template for your emails. In this example we created templates for a registration email with the following structure:
1 2 3 4 5 6 7 8 |
|
In app/views/elements/email/text/registration.ctp add:
1 2 |
|
and in app/views/layouts/email/html/default.ctp add:
1 2 |
|
In your controller enable the email component:
1
|
|
Then anywhere in your controller you can do something like the following to send an email:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|