-
Notifications
You must be signed in to change notification settings - Fork 14
/
Mail.php
738 lines (667 loc) · 24.6 KB
/
Mail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
<?php
/**
* Horde_Core_ActiveSync_Mail::
*
* @copyright 2010-2017 Horde LLC (http://www.horde.org/)
* @license http://www.horde.org/licenses/lgpl21 LGPL
* @author Michael J Rubinsky <mrubinsk@horde.org>
* @package Core
*/
/**
* Horde_Core_ActiveSync_Mail::
*
* Wraps functionality related to sending/replying/forwarding email from
* EAS clients.
*
* @copyright 2010-2017 Horde LLC (http://www.horde.org/)
* @license http://www.horde.org/licenses/lgpl21 LGPL
* @author Michael J Rubinsky <mrubinsk@horde.org>
* @package Core
*
* @property-read Horde_ActiveSync_Imap_Adapter $imapAdapter The imap adapter.
* @property boolean $replacemime Flag to indicate we are to replace the MIME contents of a SMART request.
* @property-read integer $id The UID of the source email for any SMARTREPLY or SMARTFORWARD requests.
* @property-read boolean $reply Flag indicating a SMARTREPLY request.
* @property-read boolean $forward Flag indicating a SMARTFORWARD request.
* @property-read Horde_Mime_Header $header The headers used when sending the email.
* @property-read string $parentFolder he email folder that contains the source email for any SMARTREPLY or SMARTFORWARD requests.
*/
class Horde_Core_ActiveSync_Mail
{
const HTML_BLOCKQUOTE = '<blockquote type="cite" style="border-left:2px solid blue;margin-left:2px;padding-left:12px;">';
/**
* The headers used when sending the email.
*
* @var Horde_Mime_Header
*/
protected $_headers;
/**
* The raw message body sent from the EAS client.
*
* @var Horde_ActiveSync_Rfc822
*/
protected $_raw;
/**
* The email folder that contains the source email for any SMARTREPLY or
* SMARTFORWARD requests.
*
* @var string
*/
protected $_parentFolder = false;
/**
* The UID of the source email for any SMARTREPLY or SMARTFORWARD requests.
*
* @var integer
*/
protected $_id;
/**
* Flag indicating a SMARTFORWARD request.
*
* @var boolean
*/
protected $_forward = false;
/**
* Flag indicating a SMARTREPLY request.
*
* @var boolean
*/
protected $_reply = false;
/**
* Flag indicating the client requested to replace the MIME part
* a SMARTREPLY or SMARTFORWARD request.
*
* @var boolean
*/
protected $_replacemime = false;
/**
* The current EAS user.
*
* @var string
*/
protected $_user;
/**
* Flag to indicate reply position for SMARTREPLY requests.
*
* @var boolean
*/
protected $_replyTop = false;
/**
* Internal cache of the mailer used when sending SMART[REPLY|FORWARD].
* Used to fetch the raw message used to save to sent mail folder.
*
* @var Horde_Mime_Mail
*/
protected $_mailer;
/**
* The message object representing the source email for a
* SMART[REPLY|FORWARD] request.
*
* @var Horde_ActiveSync_Imap_Message
*/
protected $_imapMessage;
/**
* The imap adapter needed to fetch the source IMAP message if needed.
*
* @var Horde_ActiveSync_Imap_Adapter
*/
protected $_imap;
/**
* EAS version in use.
*
* @var string
*/
protected $_version;
/**
* Array of email addresses to forward message to, if using SMART_FORWARD.
*
* @var array
* @since 2.31.0
*/
protected $_forwardees = array();
/**
* Const'r
*
* @param Horde_ActiveSync_Imap_Adapter $imap The IMAP adapter.
* @param string $user EAS user.
* @param integer $eas_version EAS version in use.
*/
public function __construct(
Horde_ActiveSync_Imap_Adapter $imap, $user, $eas_version)
{
$this->_imap = $imap;
$this->_user = $user;
$this->_version = $eas_version;
}
public function &__get($property)
{
switch ($property) {
case 'imapMessage':
if (!isset($this->_imapMessage)) {
$this->_getImapMessage();
}
return $this->_imapMessage;
case 'replacemime':
case 'id':
case 'reply':
case 'forward':
case 'headers':
case 'parentFolder':
$property = '_' . $property;
return $this->$property;
}
}
public function __set($property, $value)
{
if ($property == 'replacemime') {
$this->_replacemime = $value;
}
}
/**
* Set the raw message content received from the EAS client to send.
*
* @param Horde_ActiveSync_Rfc822 $raw The data from the EAS client.
*/
public function setRawMessage(Horde_ActiveSync_Rfc822 $raw)
{
$this->_headers = $raw->getHeaders();
// Attempt to always use the identity's From address, but fall back
// to the device's sent value if it's not present.
if ($from = $this->_getIdentityFromAddress()) {
$this->_headers->removeHeader('From');
$this->_headers->addHeader('From', $from);
}
// Reply-To?
if ($replyto = $this->_getReplyToAddress()) {
$this->_headers->addHeader('Reply-To', $replyto);
}
$this->_raw = $raw;
}
/**
* Set this as a SMARTFORWARD requests.
*
* @param string $parent The folder containing the source message.
* @param integer $id The source message UID.
* @param array $params Additional parameters: @since 2.31.0
* - forwardees: An array of email addresses that this message will be
* forwarded to. DEFAULT: Recipients are taken from raw
* message.
* @throws Horde_ActiveSync_Exception
*/
public function setForward($parent, $id, $params = array())
{
if (!empty($this->_reply)) {
throw new Horde_ActiveSync_Exception('Cannot set both Forward and Reply.');
}
$this->_id = $id;
$this->_parentFolder = $parent;
$this->_forward = true;
if (!empty($params['forwardees'])) {
$this->_forwardees = $params['forwardees'];
}
}
/**
* Set this as a SMARTREPLY requests.
*
* @param string $parent The folder containing the source message.
* @param integer $id The source message UID.
* @throws Horde_ActiveSync_Exception
*/
public function setReply($parent, $id)
{
if (!empty($this->_forward)) {
throw new Horde_ActiveSync_Exception('Cannot set both Forward and Reply.');
}
$this->_id = $id;
$this->_parentFolder = $parent;
$this->_reply = true;
}
/**
* Send the email.
*
* @throws Horde_ActiveSync_Exception
*/
public function send()
{
if (empty($this->_raw)) {
throw new Horde_ActiveSync_Exception('No data set or received from EAS client.');
}
$this->_callPreSendHook();
if (!$this->_parentFolder || ($this->_parentFolder && $this->_replacemime)) {
$this->_sendRaw();
} else {
$this->_sendSmart();
}
}
protected function _callPreSendHook()
{
$hooks = $GLOBALS['injector']->getInstance('Horde_Core_Hooks');
$params = array(
'raw' => $this->_raw,
'imap_msg' => $this->imapMessage,
'parent' => $this->_parentFolder,
'reply' => $this->_reply,
'forward' => $this->_forward);
try {
if (!$result = $hooks->callHook('activesync_email_presend', 'horde', array($params))) {
throw new Horde_ActiveSync_Exception('There was an issue running the activesync_email_presend hook.');
}
if ($result instanceof Horde_ActiveSync_Mime) {
$this->_raw->replaceMime($result->base);
}
} catch (Horde_Exception_HookNotSet $e) {
}
}
/**
* Get the raw message suitable for saving to the sent email folder.
*
* @return stream A stream contianing the raw message.
*/
public function getSentMail()
{
if (!empty($this->_mailer)) {
return $this->_mailer->getRaw();
}
$stream = new Horde_Stream_Temp(array('max_memory' => 262144));
$stream->add($this->_headers->toString(array('charset' => 'UTF-8')) . $this->_raw->getMessage(), true);
return $stream;
}
/**
* Send the raw message received from the client. E.g., NOT a SMART request.
*
* @throws Horde_ActiveSync_Exception
*/
protected function _sendRaw()
{
$h_array = $this->_headers->toArray(array('charset' => 'UTF-8'));
$recipients = $h_array['To'];
if (!empty($h_array['Cc'])) {
$recipients .= ',' . $h_array['Cc'];
}
if (!empty($h_array['Bcc'])) {
$recipients .= ',' . $h_array['Bcc'];
unset($h_array['Bcc']);
}
try {
$GLOBALS['injector']->getInstance('Horde_Mail')
->send($recipients, $h_array, $this->_raw->getMessage()->stream);
} catch (Horde_Mail_Exception $e) {
throw new Horde_ActiveSync_Exception($e->getMessage());
} catch (InvalidArgumentException $e) {
// Some clients (HTC One devices, for one) generate HTML signatures
// that contain line lengths too long for servers without BINARYMIME
// to send. If we are here, see if that's the reason why by trying
// to wrap any text/html parts.
if (!$this->_tryWithoutBinary($recipients, $h_array)) {
throw new Horde_ActiveSync_Exception($e->getMessage());
}
}
// Replace MIME? Don't have original body, but still need headers.
// @TODO: Get JUST the headers?
if ($this->_replacemime) {
try {
$this->_getImapMessage();
} catch (Horde_Exception_NotFound $e) {
throw new Horde_ActiveSync_Exception($e->getMessage());
}
}
}
/**
* Some clients (HTC One devices, for one) generate HTML signatures
* that contain line lengths too long for servers without BINARYMIME to
* send. If we are here, see if that's the reason by checking content
* encoding and trying again.
*
* @return boolean
*/
protected function _tryWithoutBinary($recipients, array $headers)
{
// All we need to do is re-assign the mime object. This will cause the
// content transfer encoding to be re-evaulated and set to an approriate
// value if needed.
$mime = $this->_raw->getMimeObject();
$this->_raw->replaceMime($mime);
try {
$GLOBALS['injector']->getInstance('Horde_Mail')
->send($recipients, $headers, $this->_raw->getMessage()->stream);
} catch (Exception $e) {
return false;
}
return true;
}
/**
* Sends a SMART response.
*
* @throws Horde_ActiveSync_Exception
*/
protected function _sendSmart()
{
// Need to remove content-type header from the incoming raw message
// since in a smart request, we actually construct the full MIME msg
// ourselves and the content-type in _headers only applies to the reply
// text sent from the client, not the fully generated MIME message.
$this->_headers->removeHeader('Content-Type');
$this->_headers->removeHeader('Content-Transfer-Encoding');
if ($this->_forward) {
$mail = $this->_doSmartForward();
} else {
$mail = $this->_doSmartReply();
}
try {
$mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
$this->_mailer = $mail;
} catch (Horde_Mime_Exception $e) {
throw new Horde_ActiveSync_Exception($e);
}
}
protected function _doSmartReply()
{
$mail = new Horde_Mime_Mail($this->_headers->toArray(array('charset' => 'UTF-8')));
$base_part = $this->imapMessage->getStructure();
$plain_id = $base_part->findBody('plain');
$html_id = $base_part->findBody('html');
try {
$body_data = $this->imapMessage->getMessageBodyData(array(
'protocolversion' => $this->_version,
'bodyprefs' => array(Horde_ActiveSync::BODYPREF_TYPE_MIME => true))
);
} catch (Horde_Exception_NotFound $e) {
throw new Horde_ActiveSync_Exception($e->getMessage());
}
$mime_message = $this->_raw->getMimeObject();
if (!empty($html_id)) {
$mail->setHtmlBody($this->_getHtmlPart($html_id, $mime_message, $body_data, $base_part));
} elseif (!empty($plain_id)) {
$mail->setBody($this->_getPlainPart($plain_id, $mime_message, $body_data, $base_part));
}
foreach ($mime_message->contentTypeMap() as $mid => $type) {
if ($mid != 0 && $mid != $mime_message->findBody('plain') && $mid != $mime_message->findBody('html')) {
$mail->addMimePart($mime_message->getPart($mid));
}
}
return $mail;
}
protected function _doSmartForward()
{
// Check for EAS 16.0 Forwardees
if (!empty($this->_forwardees)) {
$list = new Horde_Mail_Rfc822_List();
foreach ($this->_forwardees as $forwardee) {
$to = new Horde_Mail_Rfc822_Address($forwardee->email);
$to->personal = $forwardee->name;
$list->add($to);
}
$this->_headers->add('To', $list->writeAddress());
}
// Forwarded message
$rfc822Stream = $this->imapMessage->getFullMsg(true);
$rfc822Part = new Horde_Mime_Part();
$rfc822Part->setType("message/rfc822");
$rfc822Part->setContents($rfc822Stream);
$rfc822Part->setName(Horde_Core_Translation::t("Forwarded Message"));
// Incoming message to append to forward.
$mime_message = $this->_raw->getMimeObject();
// Outgoing message
$mail = new Horde_Mime_Mail($this->_headers->toArray(array('charset' => 'UTF-8')));
$mail->setBody($this->_getSmartPlainText($mime_message));
$mail->setHtmlBody($this->_getSmartHtmlText($mime_message));
foreach ($mime_message->contentTypeMap() as $mid => $type) {
if ($mid != 0 && $mid != $mime_message->findBody('plain') && $mid != $mime_message->findBody('html')) {
$mail->addMimePart($mime_message->getPart($mid));
}
}
$mail->addMimePart($rfc822Part);
try {
$mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
$this->_mailer = $mail;
} catch (Horde_Mime_Exception $e) {
throw new Horde_ActiveSync_Exception($e);
}
}
/**
* Build the text part of a SMARTREPLY or SMARTFORWARD
*
* @param string $plain_id The MIME part id of the plaintext
* part of $base_part.
* @param Horde_Mime_Part $mime_message The MIME part of the email to be
* sent.
* @param array $body_data @see Horde_ActiveSync_Imap_Message::getMessageBodyData()
* @param Horde_Mime_Part $base_part The base MIME part of the source
* message for a SMART request.
*
* @return string The plaintext part of the email message that is being sent.
*/
protected function _getPlainPart(
$plain_id, Horde_Mime_Part $mime_message, array $body_data, Horde_Mime_Part $base_part)
{
$smart_text = _getSmartPlainText($mime_message);
if ($this->_forward) {
return $smart_text . $this->_forwardText($body_data, $base_part->getPart($plain_id));
}
return $smart_text . $this->_replyText($body_data, $base_part->getPart($plain_id));
}
/**
* Return plain text part from incoming smart request.
*
* @param Horde_Mime_Part $mime_message Mime_Part representing the incoming msg
*
* @return string Plain text suitable for setting as the body of mime msg.
*/
protected function _getSmartPlainText(Horde_Mime_Part $mime_message)
{
if (!$id = $mime_message->findBody('plain')) {
$smart_text = Horde_ActiveSync_Utils::ensureUtf8(
$mime_message->getPart($mime_message->findBody())->getContents(),
$mime_message->getCharset()
);
$smart_text = $this->_tidyHtml($smart_text);
$smart_text = self::html2text($smart_text);
} else {
$smart_text = Horde_ActiveSync_Utils::ensureUtf8(
$mime_message->getPart($id)->getContents(),
$mime_message->getCharset());
}
return $smart_text;
}
/**
* Build the HTML part of a SMARTREPLY or SMARTFORWARD
*
* @param string $html_id The MIME part id of the html part of
* $base_part.
* @param Horde_Mime_Part $mime_message The MIME part of the email to be
* sent.
* @param array $body_data @see Horde_ActiveSync_Imap_Message::getMessageBodyData()
* @param Horde_Mime_Part $base_part The base MIME part of the source
* message for a SMART request.
*
* @return string The plaintext part of the email message that is being sent.
*/
protected function _getHtmlPart($html_id, Horde_Mime_Part $mime_message, $body_data, $base_part)
{
$smart_text = $this->_getSmartHtmlText($mime_message);
if ($this->_forward) {
return $smart_text . $this->_forwardText($body_data, $base_part->getPart($html_id), true);
}
return $smart_text . $this->_replyText($body_data, $base_part->getPart($html_id), true);
}
protected function _getSmartHtmlText(Horde_Mime_Part $mime_message)
{
if (!$id = $mime_message->findBody('html')) {
$smart_text = self::text2html(
Horde_ActiveSync_Utils::ensureUtf8(
$mime_message->getPart($mime_message->findBody('plain'))->getContents(),
$mime_message->getCharset()));
} else {
$smart_text = Horde_ActiveSync_Utils::ensureUtf8(
$mime_message->getPart($id)->getContents(),
$mime_message->getCharset());
}
return $smart_text;
}
/**
* Fetch the source message for a SMART request from the IMAP server.
*
* @throws Horde_Exception_NotFound
*/
protected function _getImapMessage()
{
if (empty($this->_id) || empty($this->_parentFolder)) {
return;
}
$this->_imapMessage = array_pop($this->_imap->getImapMessage($this->_parentFolder, $this->_id, array('headers' => true)));
if (empty($this->_imapMessage)) {
throw new Horde_Exception_NotFound('The forwarded/replied message was not found.');
}
}
/**
* Return the current user's From address.
*
* @return string A RFC822 valid email string.
*/
protected function _getIdentityFromAddress()
{
global $prefs;
$ident = $GLOBALS['injector']
->getInstance('Horde_Core_Factory_Identity')
->create($this->_user);
$as_ident = $prefs->getValue('activesync_identity');
$name = $ident->getValue('fullname', $as_ident == 'horde' ? $prefs->getValue('default_identity') : $prefs->getValue('activesync_identity'));
$from_addr = $ident->getValue('from_addr', $as_ident == 'horde' ? $prefs->getValue('default_identity') : $prefs->getValue('activesync_identity'));
if (empty($from_addr)) {
return;
}
$rfc822 = new Horde_Mail_Rfc822_Address($from_addr);
$rfc822->personal = $name;
return $rfc822->encoded;
}
/**
* Return the current user's ReplyTo address, if available.
*
* @return string A RFC822 valid email string.
*/
protected function _getReplyToAddress()
{
global $prefs;
$ident = $GLOBALS['injector']
->getInstance('Horde_Core_Factory_Identity')
->create($this->_user);
$as_ident = $prefs->getValue('activesync_identity');
$replyto_addr = $ident->getValue('replyto_addr', $as_ident == 'horde' ? $prefs->getValue('default_identity') : $prefs->getValue('activesync_identity'));
if (empty($replyto_addr)) {
return;
}
$rfc822 = new Horde_Mail_Rfc822_Address($replyto_addr);
return $rfc822->encoded;
}
/**
* Return the body of the forwarded message in the appropriate type.
*
* @param array $body_data The body data array of the source msg.
* @param Horde_Mime_Part $part The body part of the email to send.
* @param boolean $html Is this an html part?
*
* @return string The propertly formatted forwarded body text.
*/
protected function _forwardText(array $body_data, Horde_Mime_Part $part, $html = false)
{
return $this->_msgBody($body_data, $part, $html);
}
/**
* Return the body of the replied message in the appropriate type.
*
* @param array $body_data The body data array of the source msg.
* @param Horde_Mime_Part $partId The body part of the email to send.
* @param boolean $html Is this an html part?
*
* @return string The propertly formatted replied body text.
*/
protected function _replyText(array $body_data, Horde_Mime_Part $part, $html = false)
{
$msg = $this->_msgBody($body_data, $part, $html, true);
if (!empty($msg) && $html) {
return self::HTML_BLOCKQUOTE . $msg . '</blockquote><br /><br />';
}
return empty($msg)
? '[' . Horde_Core_Translation::t("No message body text") . ']'
: $msg;
}
/**
* Return the body text of the original email from a smart request.
*
* @param array $body_data The body data array of the source msg.
* @param Horde_Mime_Part $part The body mime part of the email to send.
* @param boolean $html Do we want an html body?
* @param boolean $flow Should the body be flowed?
*
* @return string The properly formatted/flowed message body.
*/
protected function _msgBody(array $body_data, Horde_Mime_Part $part, $html, $flow = false)
{
$subtype = $html == true ? 'html' : 'plain';
$msg = (string)$body_data[$subtype]['body'];
if (!$html) {
if ($part->getContentTypeParameter('format') == 'flowed') {
$flowed = new Horde_Text_Flowed($msg, 'UTF-8');
if (Horde_String::lower($part->getContentTypeParameter('delsp')) == 'yes') {
$flowed->setDelSp(true);
}
$flowed->setMaxLength(0);
$msg = $flowed->toFixed(false);
} else {
// If not flowed, remove padding at eol
$msg = preg_replace("/\s*\n/U", "\n", $msg);
}
if ($flow) {
$flowed = new Horde_Text_Flowed($msg, 'UTF-8');
$msg = $flowed->toFlowed(true);
}
} else {
return $this->_tidyHtml($msg);
}
return $msg;
}
/**
* Attempt to sanitize the provided $html string.
* Uitilizes the Cleanhtml filter if able, otherwise
* uses Horde_Dom
*
* @param string $html An HTML string to sanitize.
*
* @return string The sanitized HTML.
*/
protected function _tidyHtml($html)
{
// This filter requires the tidy extenstion.
if (Horde_Util::extensionExists('tidy')) {
return Horde_Text_Filter::filter(
$html,
'Cleanhtml',
array('body_only' => true)
);
} else {
// If no tidy, use Horde_Dom.
$dom = new Horde_Domhtml($html, 'UTF-8');
return $dom->returnBody();
}
}
/**
* Shortcut function to convert text -> HTML.
*
* @param string $msg The message text.
*
* @return string HTML text.
*/
public static function text2html($msg)
{
return Horde_Text_Filter::filter(
$msg,
'Text2html',
array(
'flowed' => self::HTML_BLOCKQUOTE,
'parselevel' => Horde_Text_Filter_Text2html::MICRO)
);
}
public static function html2text($msg)
{
return Horde_Text_Filter::filter($msg, 'Html2text', array('nestingLimit' => 1000));
}
}