本文整理汇总了PHP中AppController::__sendMail方法的典型用法代码示例。如果您正苦于以下问题:PHP AppController::__sendMail方法的具体用法?PHP AppController::__sendMail怎么用?PHP AppController::__sendMail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppController
的用法示例。
在下文中一共展示了AppController::__sendMail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __sendMail
/**
* Make sending email available to models (as well as controllers)
* Subject and message have duel meanigns if it starts with webpages. we are using the db to genetrate the message were the subject is the recored we are using
*
* @param string String - address to send email to
* @param sring $subject: subject of email |OR| Webpage to use as a template (eg. Webpages.name-of-template)
* @param string $message['html'] in the layout will be replaced with this text |OR| data array available to use for message replacement
* @param string $template to be picked from folder for email. By default, if $mail is given in any template.
* @param array address/name pairs (e.g.: array(example@address.com => name, ...)
* @param UNKNOWN Have not used it don't know what it does or if it works.
* @return bool
*/
public function __sendMail($toEmail = null, $subject = null, $message = null, $template = 'default', $from = array(), $attachment = null)
{
if ($this->notifications !== false) {
App::uses('AppController', 'Controller');
$Controller = new AppController();
if (is_array($subject)) {
// a new and improved subject over the template, this one includes a fallback message if the template doesn't exist
App::uses('Webpage', 'Webpages.Model');
$Webpage = new Webpage();
$name = str_replace('Webpages.', '', $subject['message']);
$webpage = $Webpage->findByName($name);
if (!empty($webpage)) {
// $message should be something like this : array('SomeModel' => array('some_field' => 'some_value'));
$message = $Webpage->replaceTokens($webpage['Webpage']['content'], $subject['data']);
$subject = $webpage['Webpage']['title'];
} elseif (!empty($toEmail) && !empty($subject['subjectFallback']) && !empty($subject['messageFallback'])) {
// send the fallback
return $Controller->__sendMail($toEmail, $subject['subjectFallback'], $subject['messageFallback'], $template, $from, $attachment);
} else {
throw new Exception(__('Please create an email template or fallback message.'));
}
} elseif (strpos($subject, 'Webpages.') === 0) {
App::uses('Webpage', 'Webpages.Model');
$Webpage = new Webpage();
$name = str_replace('Webpages.', '', $subject);
$webpage = $Webpage->findByName($name);
if (!empty($webpage)) {
// $message should be something like this : array('SomeModel' => array('some_field' => 'some_value'));
$message = $Webpage->replaceTokens($webpage['Webpage']['content'], $message);
$subject = $webpage['Webpage']['title'];
} else {
//Should we auto gen instead of throwing exception????
throw new Exception(__('Please create a email template named %s', $name));
}
}
return $Controller->__sendMail($toEmail, $subject, $message, $template, $from, $attachment);
}
return true;
// return true when notifications are off, so that checks don't fail
}
示例2: __sendMail
/**
* Make sending email available to models (as well as controllers)
* Subject and message have duel meanigns if it starts with webpages. we are using the db to genetrate the message were the subject is the recored we are using
*
* @param string String - address to send email to
* @param sring $subject: subject of email.
* @param string $message['html'] in the layout will be replaced with this text.
* @param string $template to be picked from folder for email. By default, if $mail is given in any template.
* @param array address/name pairs (e.g.: array(example@address.com => name, ...)
* @param UNKNOWN Have not used it don't know what it does or if it works.
* @return bool
*/
public function __sendMail($toEmail = null, $subject = null, $message = null, $template = 'default', $from = array(), $attachment = null)
{
if ($this->notifications !== false) {
App::uses('AppController', 'Controller');
$Controller = new AppController();
if (strpos($subject, 'Webpages.') === 0) {
$name = str_replace('Webpages.', '', $subject);
App::uses('Webpage', 'Webpages.Model');
$Webpage = new Webpage();
$webpage = $Webpage->findByName($name);
if (!empty($webpage)) {
// $message should be something like this : array('SomeModel' => array('some_field' => 'some_value'));
$message = $Webpage->replaceTokens($webpage['Webpage']['content'], $message);
$subject = $webpage['Webpage']['title'];
} else {
//Should we auto gen instead of throwing exception????
throw new Exception(__('Please create a email template named %s', $name));
}
}
return $Controller->__sendMail($toEmail, $subject, $message, $template, $from, $attachment);
}
}