EmailLib.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. <?php
  2. App::uses('CakeEmail', 'Network/Email');
  3. App::uses('CakeLog', 'Log');
  4. if (!defined('BR')) {
  5. define('BR', '<br />');
  6. }
  7. /**
  8. * Convenience class for internal mailer.
  9. * Adds some nice features and fixes some bugs:
  10. * - enbale embedded images in html mails
  11. * - allow setting domain for CLI environment
  12. * - enable easier attachment adding
  13. * - extensive logging and error tracing
  14. *
  15. * TODO: cleanup and more tests
  16. *
  17. * @author Mark Scherer
  18. * @license MIT
  19. * 2012-03-30 ms
  20. */
  21. class EmailLib extends CakeEmail {
  22. /**
  23. * Domain for messageId generation.
  24. * Needs to be manually set for CLI mailing as env('HTTP_HOST') is empty
  25. *
  26. * @var string
  27. */
  28. protected $_domain = null;
  29. protected $_log = null;
  30. protected $_debug = null;
  31. public $error = '';
  32. # for multiple emails, just adjust these "default" values "on the fly"
  33. public $deliveryMethod = 'mail';
  34. public $layout = 'external'; # usually 'external' (internal for admins only)
  35. # with presets, only TO/FROM (depends), subject and message has to be set
  36. public $presets = array(
  37. 'user' => '',
  38. 'admin' => '',
  39. );
  40. public $options = array();
  41. public $complex = null; # if Controller is available, and layout/elements can be switched...
  42. public function __construct($config = null) {
  43. if ($config === null) {
  44. $config = 'default';
  45. }
  46. $this->_domain = env('HTTP_HOST');
  47. if (empty($this->_domain)) {
  48. $this->_domain = php_uname('n');
  49. }
  50. parent::__construct($config);
  51. $this->resetAndSet();
  52. }
  53. /**
  54. * quick way to send emails to admin
  55. * App::uses() + EmailLib::systemEmail()
  56. *
  57. * Note: always go out with default settings (e.g.: SMTP even if debug > 0)
  58. * @return bool $success
  59. * 2011-10-31 ms
  60. */
  61. public static function systemEmail($subject, $message = 'System Email', $transportConfig = null) {
  62. $class = __CLASS__;
  63. $instance = new $class($transportConfig);
  64. $instance->to(Configure::read('Config.admin_email'));
  65. $instance->from(Configure::read('Config.admin_email'));
  66. if ($subject !== null) {
  67. $instance->subject($subject);
  68. }
  69. if (is_array($message)) {
  70. $instance->viewVars($message);
  71. $message = null;
  72. } elseif ($message === null && array_key_exists('message', $config = $instance->config())) {
  73. $message = $config['message'];
  74. }
  75. if (true || $send === true) {
  76. return $instance->send($message);
  77. }
  78. return $instance;
  79. }
  80. public function layout($layout = false) {
  81. if ($layout !== false) {
  82. $this->_layout = $layout;
  83. }
  84. return $this;
  85. }
  86. /**
  87. * @param string $file: absolute path
  88. * @param string $filename (optional)
  89. * 2011-11-02 ms
  90. */
  91. public function addAttachment($file, $name = null) {
  92. if (!empty($name)) {
  93. return $this->addAttachments(array($name=>$file));
  94. }
  95. return $this->addAttachments($file);
  96. }
  97. /**
  98. * @param string $file: absolute path
  99. * @param string $filename (optional)
  100. * @return mixed ressource $EmailLib or string $contentId
  101. * 2011-11-02 ms
  102. */
  103. public function addEmbeddedAttachment($file, $name = null, $contentId = null) {
  104. $fileInfo = array();
  105. $fileInfo['file'] = realpath($file);
  106. $fileInfo['mimetype'] = $this->_getMime($file);
  107. $fileInfo['contentId'] = $contentId ? $contentId : str_replace('-', '', String::uuid()) . '@' . $this->_domain;
  108. if (empty($name)) {
  109. $name = basename($file);
  110. }
  111. $file = array($name=>$fileInfo);
  112. $res = $this->addAttachments($file);
  113. if ($contentId === null) {
  114. return $fileInfo['contentId'];
  115. }
  116. return $res;
  117. }
  118. protected function _getMime($filename) {
  119. if (function_exists('finfo_open')) {
  120. $finfo = finfo_open(FILEINFO_MIME);
  121. $mimetype = finfo_file($finfo, $filename);
  122. finfo_close($finfo);
  123. } else {
  124. //TODO: improve
  125. $ext = pathinfo($filename, PATHINFO_EXTENSION);
  126. switch ($ext) {
  127. case "zip": $mime="application/zip"; break;
  128. case "ez": $mime="application/andrew-inset"; break;
  129. case "hqx": $mime="application/mac-binhex40"; break;
  130. case "cpt": $mime="application/mac-compactpro"; break;
  131. case "doc": $mime="application/msword"; break;
  132. case "bin": $mime="application/octet-stream"; break;
  133. case "dms": $mime="application/octet-stream"; break;
  134. case "lha": $mime="application/octet-stream"; break;
  135. case "lzh": $mime="application/octet-stream"; break;
  136. case "exe": $mime="application/octet-stream"; break;
  137. case "class": $mime="application/octet-stream"; break;
  138. case "so": $mime="application/octet-stream"; break;
  139. case "dll": $mime="application/octet-stream"; break;
  140. case "oda": $mime="application/oda"; break;
  141. case "pdf": $mime="application/pdf"; break;
  142. case "ai": $mime="application/postscript"; break;
  143. case "eps": $mime="application/postscript"; break;
  144. case "ps": $mime="application/postscript"; break;
  145. case "smi": $mime="application/smil"; break;
  146. case "smil": $mime="application/smil"; break;
  147. case "xls": $mime="application/vnd.ms-excel"; break;
  148. case "ppt": $mime="application/vnd.ms-powerpoint"; break;
  149. case "wbxml": $mime="application/vnd.wap.wbxml"; break;
  150. case "wmlc": $mime="application/vnd.wap.wmlc"; break;
  151. case "wmlsc": $mime="application/vnd.wap.wmlscriptc"; break;
  152. case "bcpio": $mime="application/x-bcpio"; break;
  153. case "vcd": $mime="application/x-cdlink"; break;
  154. case "pgn": $mime="application/x-chess-pgn"; break;
  155. case "cpio": $mime="application/x-cpio"; break;
  156. case "csh": $mime="application/x-csh"; break;
  157. case "dcr": $mime="application/x-director"; break;
  158. case "dir": $mime="application/x-director"; break;
  159. case "dxr": $mime="application/x-director"; break;
  160. case "dvi": $mime="application/x-dvi"; break;
  161. case "spl": $mime="application/x-futuresplash"; break;
  162. case "gtar": $mime="application/x-gtar"; break;
  163. case "hdf": $mime="application/x-hdf"; break;
  164. case "js": $mime="application/x-javascript"; break;
  165. case "skp": $mime="application/x-koan"; break;
  166. case "skd": $mime="application/x-koan"; break;
  167. case "skt": $mime="application/x-koan"; break;
  168. case "skm": $mime="application/x-koan"; break;
  169. case "latex": $mime="application/x-latex"; break;
  170. case "nc": $mime="application/x-netcdf"; break;
  171. case "cdf": $mime="application/x-netcdf"; break;
  172. case "sh": $mime="application/x-sh"; break;
  173. case "shar": $mime="application/x-shar"; break;
  174. case "swf": $mime="application/x-shockwave-flash"; break;
  175. case "sit": $mime="application/x-stuffit"; break;
  176. case "sv4cpio": $mime="application/x-sv4cpio"; break;
  177. case "sv4crc": $mime="application/x-sv4crc"; break;
  178. case "tar": $mime="application/x-tar"; break;
  179. case "tcl": $mime="application/x-tcl"; break;
  180. case "tex": $mime="application/x-tex"; break;
  181. case "texinfo": $mime="application/x-texinfo"; break;
  182. case "texi": $mime="application/x-texinfo"; break;
  183. case "t": $mime="application/x-troff"; break;
  184. case "tr": $mime="application/x-troff"; break;
  185. case "roff": $mime="application/x-troff"; break;
  186. case "man": $mime="application/x-troff-man"; break;
  187. case "me": $mime="application/x-troff-me"; break;
  188. case "ms": $mime="application/x-troff-ms"; break;
  189. case "ustar": $mime="application/x-ustar"; break;
  190. case "src": $mime="application/x-wais-source"; break;
  191. case "xhtml": $mime="application/xhtml+xml"; break;
  192. case "xht": $mime="application/xhtml+xml"; break;
  193. case "zip": $mime="application/zip"; break;
  194. case "au": $mime="audio/basic"; break;
  195. case "snd": $mime="audio/basic"; break;
  196. case "mid": $mime="audio/midi"; break;
  197. case "midi": $mime="audio/midi"; break;
  198. case "kar": $mime="audio/midi"; break;
  199. case "mpga": $mime="audio/mpeg"; break;
  200. case "mp2": $mime="audio/mpeg"; break;
  201. case "mp3": $mime="audio/mpeg"; break;
  202. case "aif": $mime="audio/x-aiff"; break;
  203. case "aiff": $mime="audio/x-aiff"; break;
  204. case "aifc": $mime="audio/x-aiff"; break;
  205. case "m3u": $mime="audio/x-mpegurl"; break;
  206. case "ram": $mime="audio/x-pn-realaudio"; break;
  207. case "rm": $mime="audio/x-pn-realaudio"; break;
  208. case "rpm": $mime="audio/x-pn-realaudio-plugin"; break;
  209. case "ra": $mime="audio/x-realaudio"; break;
  210. case "wav": $mime="audio/x-wav"; break;
  211. case "pdb": $mime="chemical/x-pdb"; break;
  212. case "xyz": $mime="chemical/x-xyz"; break;
  213. case "bmp": $mime="image/bmp"; break;
  214. case "gif": $mime="image/gif"; break;
  215. case "ief": $mime="image/ief"; break;
  216. case "jpeg": $mime="image/jpeg"; break;
  217. case "jpg": $mime="image/jpeg"; break;
  218. case "jpe": $mime="image/jpeg"; break;
  219. case "png": $mime="image/png"; break;
  220. case "tiff": $mime="image/tiff"; break;
  221. case "tif": $mime="image/tiff"; break;
  222. case "djvu": $mime="image/vnd.djvu"; break;
  223. case "djv": $mime="image/vnd.djvu"; break;
  224. case "wbmp": $mime="image/vnd.wap.wbmp"; break;
  225. case "ras": $mime="image/x-cmu-raster"; break;
  226. case "pnm": $mime="image/x-portable-anymap"; break;
  227. case "pbm": $mime="image/x-portable-bitmap"; break;
  228. case "pgm": $mime="image/x-portable-graymap"; break;
  229. case "ppm": $mime="image/x-portable-pixmap"; break;
  230. case "rgb": $mime="image/x-rgb"; break;
  231. case "xbm": $mime="image/x-xbitmap"; break;
  232. case "xpm": $mime="image/x-xpixmap"; break;
  233. case "xwd": $mime="image/x-xwindowdump"; break;
  234. case "igs": $mime="model/iges"; break;
  235. case "iges": $mime="model/iges"; break;
  236. case "msh": $mime="model/mesh"; break;
  237. case "mesh": $mime="model/mesh"; break;
  238. case "silo": $mime="model/mesh"; break;
  239. case "wrl": $mime="model/vrml"; break;
  240. case "vrml": $mime="model/vrml"; break;
  241. case "css": $mime="text/css"; break;
  242. case "html": $mime="text/html"; break;
  243. case "htm": $mime="text/html"; break;
  244. case "asc": $mime="text/plain"; break;
  245. case "txt": $mime="text/plain"; break;
  246. case "rtx": $mime="text/richtext"; break;
  247. case "rtf": $mime="text/rtf"; break;
  248. case "sgml": $mime="text/sgml"; break;
  249. case "sgm": $mime="text/sgml"; break;
  250. case "tsv": $mime="text/tab-separated-values"; break;
  251. case "wml": $mime="text/vnd.wap.wml"; break;
  252. case "wmls": $mime="text/vnd.wap.wmlscript"; break;
  253. case "etx": $mime="text/x-setext"; break;
  254. case "xml": $mime="text/xml"; break;
  255. case "xsl": $mime="text/xml"; break;
  256. case "mpeg": $mime="video/mpeg"; break;
  257. case "mpg": $mime="video/mpeg"; break;
  258. case "mpe": $mime="video/mpeg"; break;
  259. case "qt": $mime="video/quicktime"; break;
  260. case "mov": $mime="video/quicktime"; break;
  261. case "mxu": $mime="video/vnd.mpegurl"; break;
  262. case "avi": $mime="video/x-msvideo"; break;
  263. case "movie": $mime="video/x-sgi-movie"; break;
  264. case "asf": $mime="video/x-ms-asf"; break;
  265. case "asx": $mime="video/x-ms-asf"; break;
  266. case "wm": $mime="video/x-ms-wm"; break;
  267. case "wmv": $mime="video/x-ms-wmv"; break;
  268. case "wvx": $mime="video/x-ms-wvx"; break;
  269. case "ice": $mime="x-conference/x-cooltalk"; break;
  270. }
  271. if (empty($mime)) {
  272. $mime = 'application/octet-stream';
  273. }
  274. $mimetype = $mime;
  275. }
  276. return $mimetype;
  277. }
  278. public function preset($type = null) {
  279. # testing only:
  280. //pr ($this->Email);
  281. //pr ($this);
  282. }
  283. /**
  284. * test for a specific error
  285. * @param code: 4xx, 5xx, 5xx 5.1.1, 5xx 5.2.2, ...
  286. * @return boolean $status (TRUE only if this specific error occured)
  287. * 2010-06-08 ms
  288. */
  289. public function hasError($code) {
  290. if (!empty($this->errors)) {
  291. foreach ($this->errors as $error) {
  292. if (substr($error, 0, strlen($code)) == (string)$code) {
  293. return true;
  294. }
  295. }
  296. }
  297. return false;
  298. }
  299. public function validates() {
  300. if (!empty($this->Email->subject)) {
  301. return true;
  302. }
  303. return false;
  304. }
  305. /**
  306. * Domain as top level (the part after @)
  307. *
  308. * @param string $domain Manually set the domain for CLI mailing
  309. * @return mixed
  310. * @throws SocketException
  311. */
  312. public function domain($domain = null) {
  313. $this->_domain = $domain;
  314. return $this;
  315. }
  316. /**
  317. * Get list of headers
  318. *
  319. * ### Includes:
  320. *
  321. * - `from`
  322. * - `replyTo`
  323. * - `readReceipt`
  324. * - `returnPath`
  325. * - `to`
  326. * - `cc`
  327. * - `bcc`
  328. * - `subject`
  329. *
  330. * @param array $include
  331. * @return array
  332. */
  333. public function getHeaders($include = array()) {
  334. if ($include == array_values($include)) {
  335. $include = array_fill_keys($include, true);
  336. }
  337. $defaults = array_fill_keys(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject'), false);
  338. $include += $defaults;
  339. $headers = array();
  340. $relation = array(
  341. 'from' => 'From',
  342. 'replyTo' => 'Reply-To',
  343. 'readReceipt' => 'Disposition-Notification-To',
  344. 'returnPath' => 'Return-Path'
  345. );
  346. foreach ($relation as $var => $header) {
  347. if ($include[$var]) {
  348. $var = '_' . $var;
  349. $headers[$header] = current($this->_formatAddress($this->{$var}));
  350. }
  351. }
  352. if ($include['sender']) {
  353. if (key($this->_sender) === key($this->_from)) {
  354. $headers['Sender'] = '';
  355. } else {
  356. $headers['Sender'] = current($this->_formatAddress($this->_sender));
  357. }
  358. }
  359. foreach (array('to', 'cc', 'bcc') as $var) {
  360. if ($include[$var]) {
  361. $classVar = '_' . $var;
  362. $headers[ucfirst($var)] = implode(', ', $this->_formatAddress($this->{$classVar}));
  363. }
  364. }
  365. $headers += $this->_headers;
  366. if (!isset($headers['X-Mailer'])) {
  367. $headers['X-Mailer'] = self::EMAIL_CLIENT;
  368. }
  369. if (!isset($headers['Date'])) {
  370. $headers['Date'] = date(DATE_RFC2822);
  371. }
  372. if ($this->_messageId !== false) {
  373. if ($this->_messageId === true) {
  374. $headers['Message-ID'] = '<' . str_replace('-', '', String::UUID()) . '@' . $this->_domain . '>';
  375. } else {
  376. $headers['Message-ID'] = $this->_messageId;
  377. }
  378. }
  379. if ($include['subject']) {
  380. $headers['Subject'] = $this->_subject;
  381. }
  382. $headers['MIME-Version'] = '1.0';
  383. if (!empty($this->_attachments) || $this->_emailFormat === 'both') {
  384. $headers['Content-Type'] = 'multipart/mixed; boundary="' . $this->_boundary . '"';
  385. } elseif ($this->_emailFormat === 'text') {
  386. $headers['Content-Type'] = 'text/plain; charset=' . $this->charset;
  387. } elseif ($this->_emailFormat === 'html') {
  388. $headers['Content-Type'] = 'text/html; charset=' . $this->charset;
  389. }
  390. $headers['Content-Transfer-Encoding'] = $this->_getContentTransferEncoding();
  391. return $headers;
  392. }
  393. /**
  394. * Apply the config to an instance
  395. *
  396. * @param CakeEmail $obj CakeEmail
  397. * @param array $config
  398. * @return void
  399. * @throws ConfigureException When configuration file cannot be found, or is missing
  400. * the named config.
  401. */
  402. protected function _applyConfig($config) {
  403. if (is_string($config)) {
  404. if (!class_exists('EmailConfig') && !config('email')) {
  405. throw new ConfigureException(__d('cake_dev', '%s not found.', APP . 'Config' . DS . 'email.php'));
  406. }
  407. $configs = new EmailConfig();
  408. if (!isset($configs->{$config})) {
  409. throw new ConfigureException(__d('cake_dev', 'Unknown email configuration "%s".', $config));
  410. }
  411. $config = $configs->{$config};
  412. }
  413. $this->_config += $config;
  414. if (!empty($config['charset'])) {
  415. $this->charset = $config['charset'];
  416. }
  417. if (!empty($config['headerCharset'])) {
  418. $this->headerCharset = $config['headerCharset'];
  419. }
  420. if (empty($this->headerCharset)) {
  421. $this->headerCharset = $this->charset;
  422. }
  423. $simpleMethods = array(
  424. 'from', 'sender', 'to', 'replyTo', 'readReceipt', 'returnPath', 'cc', 'bcc',
  425. 'messageId', 'domain', 'subject', 'viewRender', 'viewVars', 'attachments',
  426. 'transport', 'emailFormat'
  427. );
  428. foreach ($simpleMethods as $method) {
  429. if (isset($config[$method])) {
  430. $this->$method($config[$method]);
  431. unset($config[$method]);
  432. }
  433. }
  434. if (isset($config['headers'])) {
  435. $this->setHeaders($config['headers']);
  436. unset($config['headers']);
  437. }
  438. if (array_key_exists('template', $config)) {
  439. $layout = false;
  440. if (array_key_exists('layout', $config)) {
  441. $layout = $config['layout'];
  442. unset($config['layout']);
  443. }
  444. $this->template($config['template'], $layout);
  445. unset($config['template']);
  446. }
  447. $this->transportClass()->config($config);
  448. }
  449. /**
  450. * Set the body of the mail as we send it.
  451. * Note: the text can be an array, each element will appear as a seperate line in the message body.
  452. * @param string/array: message
  453. * LEAVE empty if you use $this->set() in combination with templates
  454. */
  455. public function send($message = null) {
  456. $this->_log = array(
  457. 'to' => $this->_to,
  458. 'from' => $this->_from,
  459. 'sender' => $this->_sender,
  460. 'replyTo' => $this->_replyTo,
  461. 'cc' => $this->_cc,
  462. 'subject' => $this->_subject,
  463. 'cc' => $this->_cc,
  464. 'transport' => $this->_transportName
  465. );
  466. # prep images for inline
  467. /*
  468. if ($this->_emailFormat !== 'text') {
  469. if ($message !== null) {
  470. $message = $this->_prepMessage($message);
  471. } else {
  472. $this->_htmlMessage = $this->_prepMessage($this->_htmlMessage);
  473. }
  474. }
  475. */
  476. try {
  477. $this->_debug = parent::send($message);
  478. } catch (Exception $e) {
  479. $this->error = $e->getMessage();
  480. $this->error .= ' (line '.$e->getLine().' in '.$e->getFile().')'.PHP_EOL.$e->getTraceAsString();
  481. if (!empty($this->_config['report'])) {
  482. $this->_logEmail();
  483. }
  484. return false;
  485. }
  486. if (!empty($this->_config['report'])) {
  487. $this->_logEmail();
  488. }
  489. return true;
  490. }
  491. protected function _prepMessage($text) {
  492. return $text;
  493. }
  494. /**
  495. * @return string
  496. */
  497. public function getError() {
  498. return $this->error;
  499. }
  500. protected function _logEmail($append = null) {
  501. $res = $this->_log['transport'].
  502. ' - '.'TO:'.implode(',', array_keys($this->_log['to'])).
  503. '||FROM:'.implode(',', array_keys($this->_log['from'])).
  504. '||REPLY:'.implode(',', array_keys($this->_log['replyTo'])).
  505. '||S:'.$this->_log['subject'];
  506. $type = 'email';
  507. if (!empty($this->error)) {
  508. $type = 'email_error';
  509. $res .= '||ERROR:' . $this->error;
  510. }
  511. if ($append) {
  512. $res .= '||'.$append;
  513. }
  514. CakeLog::write($type, $res);
  515. }
  516. /**
  517. * toggle debug mode
  518. * 2011-05-27 ms
  519. */
  520. public function debug($mode = null) {
  521. if ($mode) {
  522. $this->debug = true;
  523. //$this->delivery('debug');
  524. } else {
  525. $this->debug = false;
  526. //$this->delivery($this->deliveryMethod);
  527. }
  528. }
  529. public function resetAndSet() {
  530. $this->_to = array();
  531. $this->_cc = array();
  532. $this->_bcc = array();
  533. $this->_messageId = true;
  534. $this->_subject = '';
  535. $this->_headers = array();
  536. $this->_viewVars = array();
  537. $this->_textMessage = '';
  538. $this->_htmlMessage = '';
  539. $this->_message = '';
  540. $this->_attachments = array();
  541. $this->from(Configure::read('Config.admin_email'), Configure::read('Config.admin_emailname'));
  542. if ($xMailer = Configure::read('Config.x-mailer')) {
  543. $this->addHeaders(array('X-Mailer'=>$xMailer));
  544. }
  545. //$this->errors = array();
  546. //$this->charset($this->charset);
  547. //$this->sendAs($this->sendAs);
  548. //$this->layout($this->layout);
  549. //$this->delivery($this->deliveryMethod);
  550. }
  551. public function reset() {
  552. parent::reset();
  553. $this->error = '';
  554. $this->_debug = null;
  555. }
  556. public function flashDebug() {
  557. $info = $this->Email->Controller->Session->read('Message.email.message');
  558. if (empty($info)) {
  559. $info = $this->Email->Controller->Session->read('Message.email.message');
  560. }
  561. $info .= BR;
  562. $info .= h($this->_logMessage());
  563. $this->Email->Controller->Session->delete('Message.email');
  564. $this->Email->Controller->flashMessage($info, 'info');
  565. if (!empty($this->errors)) {
  566. $this->Email->Controller->flashMessage(implode(BR, $this->errors), 'error');
  567. }
  568. }
  569. }