The Pimcore_Mail Class extend the Zend_Mail Class and adds some features for the usage with pimcore.
When you create a new Pimcore_Mail instance the E-Mail settings from "Settings" -> "System" -> "Email Settings" are automatically applied.
If the Debug Mode in "Settings" -> "System" -> "Debug" is enabled, all emails will be sent to the Debug Email recipients defined in "Settings" -> "System" -> "Email Settings" -> "Debug Email Addresses". Additionaly the debug information (to whom the email would have been sent) is appended to the email and the Subject contains the prefix "Debug email:".
The Pimcore_Mail Class automatically takes care of the nasty stuff (emedding css, compiling less files, normalizing urls, replacement of Dynamic Placeholders...). Note that all css files are embedded to the html with a "style" tag because the image paths are also normalised.
If "html2text" from Martin Bayer (http://www.mbayer.de/html2text/index.shtml) is installed on the server, a text version from the html email will automatically be created.
On Debian you can install it with:
apt-get install html2text
Useful methods:
| Method | Description |
|---|---|
| disableLogging() | Disables email logging - by default it is enabled |
| setParams(array) |
Sets the parameters for the email view and the Placeholders |
| setParam($key, $value) |
Sets a single parameter for the email view and the Placeholders |
| isValidEmailAddress(emailAddress) |
Static helper to validate a email address |
| setDocument(Document_Email) |
Sets the email document |
| getDocument() |
Returns the Document |
| getSubjectRendered() | Replaces the placeholders with the content and returns the rendered Subject |
| getBodyHtmlRendered() |
Replaces the placeholders with the content and returns the rendered Html |
| getBodyTextRendered() |
* Replaces the placeholders with the content and returns * the rendered text if a text was set with "$mail->setBodyText()" * * If html2text is installed a text version on the html email will be automatically created Replaces the placeholders with the content and returns the rendered text if a text was set with "$mail->setBodyText()" If html2text is installed a text version on the html email will be automatically created |
Class Location: /pimcore/lib/Pimcore/Mail.php
Usage example
$params = array('firstName' => 'Pim',
'lastName' => 'Core',
'product' => 73613);
//sending the email
$mail = new Pimcore_Mail();
$mail->addTo('example@pimcore.org');
$mail->setDocument('/email/myemaildocument');
$mail->setParams($params);
$mail->send();
Comments (1)
Feb 29
christian bretzke says:
I'd like to know how to access from my controller (without entering a debug-emai...I'd like to know how to access from my controller (without entering a debug-email-adress) the email-adresses i placed in settings->system->email_settings->return_email
can anyone get me a hint pls?
thx anyway =)