forked from pimcore/pimcore
/
Mail.php
919 lines (794 loc) · 25.8 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
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
<?php
/**
* Pimcore
*
* This source file is subject to the GNU General Public License version 3 (GPLv3)
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
* files that are distributed with this source code.
*
* @copyright Copyright (c) 2009-2016 pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GNU General Public License version 3 (GPLv3)
*/
namespace Pimcore;
use Pimcore\Helper\Mail as MailHelper;
use Pimcore\Model;
class Mail extends \Zend_Mail
{
/**
* Contains the debug email addresses from settings -> system -> Email Settings -> Debug email addresses
*
* @var array
* @static
*/
protected static $debugEmailAddresses = array();
/**
* @var object Pimcore_Placeholder
*/
protected $placeholderObject;
/**
* Contains data that has to be stored temporary e.g. email receivers for logging
*
* @var array
*/
protected $temporaryStorage = array();
/**
* If true - emails are logged in the database and on the file-system
*
* @var bool
*/
protected $loggingEnable = true;
/**
* Contains the email document
*
* @var Model\Document\Email
*/
protected $document;
/**
* Contains the dynamic Params for the Placeholders
*
* @var array
*/
protected $params = array();
/**
* html2text from mbayer is installed (http://www.mbayer.de/html2text/)
*
* @var bool
*/
protected static $html2textInstalled = null;
/**
* Options passed to html2text
*
* @var string
*/
protected $html2textOptions = "";
/**
* use html2text from mbayer if it is installed (http://www.mbayer.de/html2text/)
*
* @var boolean
*/
protected $html2textBinaryEnabled = null;
/**
* Prevent adding debug information
*
* @var bool
*/
protected $preventDebugInformationAppending = false;
/**
* if true - the Pimcore debug mode is ignored
* @var bool
*/
protected $ignoreDebugMode = false;
/**
* if true - the layout is enabled when document is rendered to a string
* @var bool
*/
protected $enableLayoutOnPlaceholderRendering = true;
/**
* forces the mail class to always us the "Pimcore Mode",
* so you don't have to set the charset every time when you create new Pimcore_Mail instance
* @var bool
*/
public static $forcePimcoreMode = false;
/**
* if $hostUrl is set - this url well be used to create absolute urls
* otherwise it is determined automatically
* @see MailHelper::setAbsolutePaths()
*
* @var null
*/
protected $hostUrl = null;
/**
* @param $url
* @return $this
*/
public function setHostUrl($url){
$this->hostUrl = $url;
return $this;
}
/**
* @return null
*/
public function getHostUrl(){
return $this->hostUrl;
}
// true - prevent setting the recipients from the Document - set in $this->clearRecipients()
/**
* @var bool
*/
protected $recipientsCleared = false;
/**
* @param null $charset
* @throws \Exception
* @throws \Zend_Mail_Exception
*/
public function __construct($charset = null)
{
// using $charset as param to be compatible with \Zend_Mail
if(is_array($charset) || self::$forcePimcoreMode) {
$options = $charset;
parent::__construct($options["charset"] ? $options["charset"] : "UTF-8");
if ($options["document"]) {
$this->setDocument($options["document"]);
}
if ($options['params']) {
$this->setParams($options['params']);
}
if ($options['subject']) {
$this->setSubject($options['subject']);
}
if ($options['hostUrl']) {
$this->setHostUrl($options['hostUrl']);
}
} else {
if($charset === null) {
$charset = "UTF-8";
}
parent::__construct($charset);
}
$this->init();
}
/**
* Initializes the mailer with the settings form Settings -> System -> Email Settings
*
* @return void
*/
public function init($type = "email")
{
$systemConfig = \Pimcore\Config::getSystemConfig()->toArray();
$emailSettings =& $systemConfig[$type];
if ($emailSettings['sender']['email']) {
\Zend_Mail::setDefaultFrom($emailSettings['sender']['email'], $emailSettings['sender']['name']);
}
if ($emailSettings['return']['email']) {
\Zend_Mail::setDefaultReplyTo($emailSettings['return']['email'], $emailSettings['return']['name']);
}
if ($emailSettings['method'] == "smtp") {
$config = array();
if ($emailSettings['smtp']['name']) {
$config['name'] = $emailSettings['smtp']['name'];
}
if ($emailSettings['smtp']['ssl']) {
$config['ssl'] = $emailSettings['smtp']['ssl'];
}
if ($emailSettings['smtp']['port']) {
$config['port'] = $emailSettings['smtp']['port'];
}
if ($emailSettings['smtp']['auth']['method']) {
$config['auth'] = $emailSettings['smtp']['auth']['method'];
$config['username'] = $emailSettings['smtp']['auth']['username'];
$config['password'] = $emailSettings['smtp']['auth']['password'];
}
$transport = new \Zend_Mail_Transport_Smtp($emailSettings['smtp']['host'], $config);
\Zend_Mail::setDefaultTransport($transport);
}
//setting debug email addresses
if ($type == "email" && empty(self::$debugEmailAddresses)) {
if ($emailSettings['debug']['emailaddresses']) {
foreach (explode(',', $emailSettings['debug']['emailaddresses']) as $emailAddress) {
self::$debugEmailAddresses[] = $emailAddress;
}
}
}
$this->placeholderObject = new \Pimcore\Placeholder();
}
/**
* @param $value
* @return $this
*/
public function setIgnoreDebugMode($value){
$this->ignoreDebugMode = (bool)$value;
return $this;
}
/**
* Checks if the Debug mode is ignored
*
* @return bool
*/
public function getIgnoreDebugMode(){
return $this->ignoreDebugMode;
}
/**
* @param $value
* @return $this
*/
public function setEnableLayoutOnPlaceholderRendering($value){
$this->enableLayoutOnPlaceholderRendering = (bool)$value;
return $this;
}
/**
* @return bool
*/
public function getEnableLayoutOnPlaceholderRendering(){
return $this->enableLayoutOnPlaceholderRendering;
}
/**
* Determines if mbayer html2text is installed (more information at http://www.mbayer.de/html2text/)
* and uses it to automatically create a text version of the html email
*
* @static
* @return void
*/
public static function determineHtml2TextIsInstalled() {
self::$html2textInstalled = false;
$paths = array("/usr/bin/html2text","/usr/local/bin/html2text", "/bin/html2text");
foreach ($paths as $path) {
if(@is_executable($path)) {
self::$html2textInstalled = true;
return true;
}
}
}
/**
* Sets options that are passed to html2text
*
* @param string $options
* @return \Pimcore\Mail
*/
public function setHtml2TextOptions($options = ''){
if(is_string($options)){
$this->html2textOptions = $options;
}else{
\Logger::warn('Html2Text options ignored. You have to pass a string');
}
return $this;
}
/**
* Returns options for html2text
*
* @return string
*/
public function getHtml2TextOptions(){
return $this->html2textOptions;
}
// overwriting \Zend_Mail methods - necessary for logging... - start
/**
* Adds To-header and recipient, $email can be an array, or a single string address
* Additionally adds recipients to temporary storage
*
* @param string|array $email
* @param string $name
* @return \Pimcore\Mail Provides fluent interface
*/
public function addTo($email, $name = '')
{
$this->addToTemporaryStorage('To', $email, $name);
return parent::addTo($email, $name);
}
/**
* Adds Cc-header and recipient, $email can be an array, or a single string address
* Additionally adds recipients to temporary storage
*
* @param string|array $email
* @param string $name
* @return Pimcore_Mail Provides fluent interface
*/
public function addCc($email, $name = '')
{
$this->addToTemporaryStorage('Cc', $email, $name);
return parent::addCc($email, $name);
}
/**
* Adds Bcc recipient, $email can be an array, or a single string address
* Additionally adds recipients to temporary storage
*
* @param string|array $email
* @return \Pimcore\Mail Provides fluent interface
*/
public function addBcc($email)
{
$this->addToTemporaryStorage('Bcc', $email, '');
return parent::addBcc($email);
}
/**
* Clears list of recipient email addresses
* and resets the temporary storage
*
* @return \Pimcore\Mail Provides fluent interface
*/
public function clearRecipients()
{
unset($this->temporaryStorage['To']);
unset($this->temporaryStorage['Cc']);
unset($this->temporaryStorage['Bcc']);
$this->recipientsCleared = true;
return parent::clearRecipients();
}
// overwriting \Zend_Mail methods - end
/**
* Helper to add receivers to the temporary storage
*
* @param string $key
* @param string | array $email
* @param string $name
*/
protected function addToTemporaryStorage($key, $email, $name)
{
if (!is_array($email)) {
$email = array($name => $email);
}
foreach ($email as $n => $recipient) {
$this->temporaryStorage[$key][] = array('email' => $recipient, 'name' => is_int($n) ? '' : $n);
}
}
/**
* Returns the temporary storage
*
* @return array
*/
public function getTemporaryStorage()
{
return $this->temporaryStorage;
}
/**
* Disables email logging
*
* @return \Pimcore\Mail Provides fluent interface
*/
public function disableLogging()
{
$this->loggingEnable = false;
return $this;
}
/**
* Enables email logging (by default it's enabled)
*
* @return \Pimcore\Mail Provides fluent interface
*/
public function enableLogging()
{
$this->loggingEnable = true;
return $this;
}
/**
* returns the logging status
*
* @return bool
*/
public function loggingIsEnabled()
{
return $this->loggingEnable;
}
/**
* Sets the parameters for the email view and the Placeholders
*
* @param array $params
* @return \Pimcore\Mail Provides fluent interface
*/
public function setParams(Array $params)
{
foreach ($params as $key => $value) {
$this->setParam($key, $value);
}
return $this;
}
/**
* Sets a single parameter for the email view and the Placeholders
*
* @param string | int $key
* @param mixed $value
* @return \Pimcore\Mail Provides fluent interface
*/
public function setParam($key, $value)
{
if (is_string($key) || is_integer($key)) {
$this->params[$key] = $value;
} else {
\Logger::warn('$key has to be a string - Param ignored!');
}
return $this;
}
/**
* Returns the parameters which were set with "setParams" or "setParam"
*
* @return array
*/
public function getParams()
{
return $this->params;
}
/**
* Returns a parameter which was set with "setParams" or "setParam"
*
* @param string | integer $key
* @return mixed
*/
public function getParam($key)
{
return $this->params[$key];
}
/**
* Deletes parameters which were set with "setParams" or "setParam"
*
* @param array $params
* @return \Pimcore\Mail Provides fluent interface
*/
public function unsetParams(Array $params)
{
foreach ($params as $param) {
$this->unsetParam($param);
}
return $this;
}
/**
* Deletes a single parameter which was set with "setParams" or "setParam"
*
* @param string | integer $key
* @return \Pimcore\Mail Provides fluent interface
*/
public function unsetParam($key)
{
if (is_string($key) || is_integer($key)) {
unset($this->params[$key]);
} else {
\Logger::warn('$key has to be a string - unsetParam ignored!');
}
return $this;
}
/**
* Sets the settings which are defined in the Document Settings (from,to,cc,bcc)
*
* @return \Pimcore\Mail Provides fluent interface
*/
protected function setDocumentSettings()
{
$document = $this->getDocument();
if ($document instanceof Model\Document\Email) {
if(!$this->recipientsCleared){
$to = $document->getToAsArray();
if (!empty($to)) {
$this->addTo($to);
}
$cc = $document->getCcAsArray();
if (!empty($cc)) {
$this->addCc($cc);
}
$bcc = $document->getBccAsArray();
if (!empty($bcc)) {
$this->addBcc($bcc);
}
}
//if more than one "from" email address is defined -> we set the first one
$fromArray = $document->getFromAsArray();
if(!empty($fromArray)) {
list($from) = $fromArray;
if ($from) {
$this->clearFrom();
$this->setFrom($from);
}
}
}
return $this;
}
/**
* @param string $email
* @param null $name
* @return \Zend_Mail
* @throws \Zend_Mail_Exception
*/
public function setFrom($email, $name = null)
{
$this->_from = null;
$this->clearHeader("From");
return parent::setFrom($email, $name); // TODO: Change the autogenerated stub
}
/**
*
*/
public function setTo($email, $name = '') {
$this->_to = [];
$this->_recipients = [];
$this->clearHeader("To");
$this->addTo($email, $name);
}
/**
* Sends this email using the given transport or with the settings from "Settings" -> "System" -> "Email Settings"
*
* IMPORTANT: If the debug mode is enabled in "Settings" -> "System" -> "Debug" all emails will be sent to the
* debug email addresses that are given in "Settings" -> "System" -> "Email Settings" -> "Debug email addresses"
*
* set DefaultTransport or the internal mail function if no
* default transport had been set.
*
* @param \Zend_Mail_Transport_Abstract $transport
* @return \Pimcore\Mail Provides fluent interface
*/
public function send($transport = null)
{
// filter email addresses
$blockedAddresses = array();
foreach ($this->getRecipients() as $recipient) {
if(Model\Tool\Email\Blacklist::getByAddress($recipient)) {
$blockedAddresses[] = $recipient;
}
}
if(!empty($blockedAddresses)) {
foreach ($blockedAddresses as $blockedAddress) {
foreach (["To", "Cc", "Bcc"] as $type) {
$tmp = $this->_headers[$type];
foreach ($tmp as $key => &$value) {
if(strpos($value, $blockedAddress) !== false) {
unset($this->_headers[$type][$key]);
unset($this->_recipients[$value]);
}
}
}
}
}
$this->setSubject($this->getSubjectRendered());
$bodyHtmlRendered = $this->getBodyHtmlRendered();
if($bodyHtmlRendered){
$this->setBodyHtml($bodyHtmlRendered);
}
$bodyTextRendered = $this->getBodyTextRendered();
if($bodyTextRendered){
$this->setBodyText($bodyTextRendered);
}
if($this->ignoreDebugMode == false){
$this->checkDebugMode();
}
$result = parent::send($transport);
if ($this->loggingIsEnabled()) {
try {
MailHelper::logEmail($this);
} catch (\Exception $e) {
\Logger::emerg("Couldn't log Email");
}
}
return $result;
}
/**
* @throws \Exception
* @throws \Zend_Mail_Exception
*/
protected function checkDebugMode()
{
if (\Pimcore::inDebugMode()) {
if (empty(self::$debugEmailAddresses)) {
throw new \Exception('No valid debug email address given in "Settings" -> "System" -> "Email Settings"');
}
if($this->preventDebugInformationAppending != true){
//adding the debug information to the html email
$html = $this->getBodyHtml();
if ($html instanceof \Zend_Mime_Part) {
$rawHtml = $html->getRawContent();
$debugInformation = MailHelper::getDebugInformation('html', $this);
$debugInformationStyling = MailHelper::getDebugInformationCssStyle();
$rawHtml = preg_replace("!(</\s*body\s*>)!is", "$debugInformation\\1", $rawHtml);
$rawHtml = preg_replace("!(<\s*head\s*>)!is", "\\1$debugInformationStyling", $rawHtml);
$this->setBodyHtml($rawHtml);
}
$text = $this->getBodyText();
if($text instanceof \Zend_Mime_Part){
$rawText = $text->getRawContent();
$debugInformation = MailHelper::getDebugInformation('text',$this);
$rawText .= $debugInformation;
$this->setBodyText($rawText);
}
//setting debug subject
$subject = $this->getSubject();
$this->clearSubject();
$this->setSubject('Debug email: ' . $subject);
}
$this->clearRecipients();
$this->addTo(self::$debugEmailAddresses);
}
}
/**
* Static helper to validate a email address
*
* @static
* @param $emailAddress
* @return bool
*/
public static function isValidEmailAddress($emailAddress)
{
$validator = new \Zend_Validate_EmailAddress();
return $validator->isValid($emailAddress);
}
/**
* Replaces the placeholders with the content and returns the rendered Subject
*
* @return string
*/
public function getSubjectRendered()
{
$subject = $this->getSubject();
$this->clearSubject();
if (!$subject && $this->getDocument()) {
$subject = $this->getDocument()->getSubject();
}
return $this->placeholderObject->replacePlaceholders($subject, $this->getParams(), $this->getDocument(),$this->getEnableLayoutOnPlaceholderRendering());
}
/**
* Replaces the placeholders with the content and returns the rendered Html
*
* @return string|null
*/
public function getBodyHtmlRendered()
{
$html = $this->getBodyHtml();
//if the content was manually set with $obj->setBodyHtml(); this content will be used
//and not the content of the Document!
if ($html instanceof \Zend_Mime_Part) {
$rawHtml = $html->getRawContent();
$content = $this->placeholderObject->replacePlaceholders($rawHtml, $this->getParams(), $this->getDocument(),$this->getEnableLayoutOnPlaceholderRendering());
} elseif ($this->getDocument() instanceof Model\Document) {
$content = $this->placeholderObject->replacePlaceholders($this->getDocument(), $this->getParams(), $this->getDocument(),$this->getEnableLayoutOnPlaceholderRendering());
} else {
$content = null;
}
//modifying the content e.g set absolute urls...
if ($content) {
$content = MailHelper::embedAndModifyCss($content, $this->getDocument());
$content = MailHelper::setAbsolutePaths($content, $this->getDocument(), $this->getHostUrl());
}
return $content;
}
/**
* Replaces the placeholders with the content and returns
* the rendered text if a text was set with "$mail->setBodyText()" *
* @return string
*/
public function getBodyTextRendered()
{
$text = $this->getBodyText();
//if the content was manually set with $obj->setBodyText(); this content will be used
if ($text instanceof \Zend_Mime_Part) {
$rawText = $text->getRawContent();
$content = $this->placeholderObject->replacePlaceholders($rawText, $this->getParams(), $this->getDocument(),$this->getEnableLayoutOnPlaceholderRendering());
} else {
//creating text version from html email if html2text is installed
try {
include_once("simple_html_dom.php");
include_once("html2text.php");
$htmlContent = $this->getBodyHtmlRendered();
$html = str_get_html($htmlContent);
if($html) {
$body = $html->find("body",0);
if($body) {
$style = $body->find("style",0);
if ($style){
$style->clear();
}
$htmlContent = $body->innertext;
}
$html->clear();
unset($html);
}
$content = $this->html2Text($htmlContent);
} catch (\Exception $e) {
\Logger::err($e);
$content = "";
}
}
return $content;
}
/**
* @param $document
* @return $this
* @throws \Exception
*/
public function setDocument($document)
{
if ($document instanceof Model\Document) { //document passed
$this->document = $document;
$this->setDocumentSettings();
} elseif ((int)$document > 0) { //id of document passed
$this->setDocument(Model\Document::getById($document));
} elseif (is_string($document) && $document != "") { //path of document passed
$this->setDocument(Model\Document::getByPath($document));
} else {
throw new \Exception("$document is not an instance of \\Document\\Email or at least \\Document");
}
return $this;
}
/**
* Returns the Document
*
* @return Model\Document\Email | null
*/
public function getDocument()
{
return $this->document;
}
/**
* Prevents appending of debug information (used for resending emails)
*
* @return \Pimcore\Mail
*/
public function preventDebugInformationAppending(){
$this->preventDebugInformationAppending = true;
return $this;
}
/**
*
* @return boolean
*/
public function getHtml2TextBinaryEnabled()
{
return $this->html2textBinaryEnabled;
}
/**
* @return $this
* @throws \Exception
*/
public function enableHtml2textBinary()
{
if (self::getHtml2textInstalled()){
$this->html2textBinaryEnabled = true;
} else {
throw new \Exception("trying to enable html2text binary,
but html2text is not installed!");
}
return $this;
}
/**
* @static
* returns html2text binary installation status
* @return boolean || null
*/
public static function getHtml2textInstalled()
{
if (is_null(self::$html2textInstalled)){
self::determineHtml2TextIsInstalled();
}
return self::$html2textInstalled;
}
/**
* generates text version of htmlContent
* uses html2text binary if it was successfully enabled by calling
* enableHtml2textBinary(), otherwise it uses html2text php version
* @returns string
*/
protected function html2Text($htmlContent)
{
if ($this->getHtml2TextBinaryEnabled()){
$content = "";
//html2text doesn't support unicode
if ($this->getCharset()=="UTF-8"){
$htmlContent = utf8_decode($htmlContent);
}
//using temporary file so we don't have problems with special characters
$tmpFileName = PIMCORE_TEMPORARY_DIRECTORY . "/" . uniqid('email_', true) . ".tmp";
if (\Pimcore\File::put($tmpFileName, $htmlContent)) {
$content = @shell_exec("html2text $tmpFileName " . $this->getHtml2TextOptions());
@unlink($tmpFileName);
}
return $content;
} else {
return @html2text($htmlContent);
}
}
/**
* Sets From-header and sender of the message
*
* @param string $email
* @return \Zend_Mail Provides fluent interface
*/
public function setSender($email) {
$email = $this->_filterEmail($email);
$this->sender = $email;
$this->_storeHeader('Sender', $this->_formatAddress($email,null), true);
return $this;
}
}