CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

Email.php
Go to the documentation of this file.
1 <?PHP
2 #
3 # FILE: Email.php
4 #
5 # Part of the ScoutLib application support library
6 # Copyright 2012-2015 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu
8 #
9
14 class Email
15 {
16
17 # ---- PUBLIC INTERFACE --------------------------------------------------
18 /*@(*/
20
28 public function Send()
29 {
30 # if whitelist set
31 if (count(self::$RecipientWhitelist))
32 {
33 # save recipient list and then pare it down based on whitelist
34 $SavedTo = $this->To;
35 $NewTo = array();
36 foreach ($this->To as $To)
37 {
38 foreach (self::$RecipientWhitelist as $White)
39 {
40 $White = trim($White);
41 if (StdLib::substr($White, 0, 1) != StdLib::substr($White, -1))
42 {
43 $White = "/".preg_quote($White, "/")."/";
44 }
45 if (preg_match($White, $To))
46 {
47 $NewTo[] = $To;
48 continue 2;
49 }
50 }
51 }
52 $this->To = $NewTo;
53 }
54
55 # if there are recipients
56 $Result = TRUE;
57 if (count($this->To))
58 {
59 switch (self::$DeliveryMethod)
60 {
61 case self::METHOD_PHPMAIL:
62 # use PHPMailer to send multipart alternative messages because
63 # they can be tricky to construct properly
64 if ($this->HasAlternateBody())
65 {
66 $Result = $this->SendViaPhpMailerLib();
67 }
68
69 # otherwise, just use the built-in mail() function
70 else
71 {
72 $Result = $this->SendViaPhpMailFunc();
73 }
74 break;
75
76 case self::METHOD_SMTP:
77 $Result = $this->SendViaSmtp();
78 break;
79 }
80
81 # log if a message was sent
82 if ($Result && self::$LoggingFunc !== NULL)
83 {
84 call_user_func(self::$LoggingFunc, $this, $this->LogData);
85 }
86 }
87
88 # if recipient list saved
89 if (isset($SavedTo))
90 {
91 # restore recipient list
92 $this->To = $SavedTo;
93 }
94
95 # report to caller whether message was sent
96 return $Result;
97 }
98
107 public static function ToWhitelist($NewValue = NULL)
108 {
109 if ($NewValue !== NULL)
110 {
111 self::$RecipientWhitelist = $NewValue;
112 }
113 return self::$RecipientWhitelist;
114 }
115
121 public static function RegisterLoggingFunction($NewValue)
122 {
123 if (!is_callable($NewValue))
124 {
125 throw new Exception(
126 "Invalid logging function provided.");
127 }
128 self::$LoggingFunc = $NewValue;
129 }
130
136 public function AddLogData($LogData)
137 {
138 $this->LogData = $LogData;
139 }
140 /*@(*/
142
148 public function Body($NewValue = NULL)
149 {
150 if ($NewValue !== NULL) { $this->Body = $NewValue; }
151 return $this->Body;
152 }
153
159 public function AlternateBody($NewValue = NULL)
160 {
161 # set the plain-text alternative if a parameter is given
162 if (func_num_args() > 0)
163 {
164 $this->AlternateBody = $NewValue;
165 }
166
167 return $this->AlternateBody;
168 }
169
175 public function Subject($NewValue = NULL)
176 {
177 if ($NewValue !== NULL) { $this->Subject = $NewValue; }
178 return $this->Subject;
179 }
180
189 public function From($NewAddress = NULL, $NewName = NULL)
190 {
191 if ($NewAddress !== NULL)
192 {
193 $NewAddress = trim($NewAddress);
194 if ($NewName !== NULL)
195 {
196 $NewName = trim($NewName);
197 $this->From = $NewName." <".$NewAddress.">";
198 }
199 else
200 {
201 $this->From = $NewAddress;
202 }
203 }
204 return $this->From;
205 }
206
213 public static function DefaultFrom($NewValue = NULL)
214 {
215 if ($NewValue !== NULL) { self::$DefaultFrom = $NewValue; }
216 return self::$DefaultFrom;
217 }
218
227 public function ReplyTo($NewAddress = NULL, $NewName = NULL)
228 {
229 if ($NewAddress !== NULL)
230 {
231 $NewAddress = trim($NewAddress);
232 if ($NewName !== NULL)
233 {
234 $NewName = trim($NewName);
235 $this->ReplyTo = $NewName." <".$NewAddress.">";
236 }
237 else
238 {
239 $this->ReplyTo = $NewAddress;
240 }
241 }
242 return $this->ReplyTo;
243 }
244
252 public function To($NewValue = NULL)
253 {
254 if ($NewValue !== NULL)
255 {
256 if (!is_array($NewValue))
257 {
258 $this->To = array($NewValue);
259 }
260 else
261 {
262 $this->To = $NewValue;
263 }
264 }
265 return $this->To;
266 }
267
275 public function CC($NewValue = NULL)
276 {
277 if ($NewValue !== NULL)
278 {
279 if (!is_array($NewValue))
280 {
281 $this->CC = array($NewValue);
282 }
283 else
284 {
285 $this->CC = $NewValue;
286 }
287 }
288 return $this->CC;
289 }
290
298 public function BCC($NewValue = NULL)
299 {
300 if ($NewValue !== NULL)
301 {
302 if (!is_array($NewValue))
303 {
304 $this->BCC = array($NewValue);
305 }
306 else
307 {
308 $this->BCC = $NewValue;
309 }
310 }
311 return $this->BCC;
312 }
313
318 public function AddHeaders($NewHeaders)
319 {
320 # add new headers to list
321 $this->Headers = array_merge($this->Headers, $NewHeaders);
322 }
323
330 public function CharSet($NewValue = NULL)
331 {
332 # set the plain-text alternative if a parameter is given
333 if (func_num_args() > 0)
334 {
335 $this->CharSet = $NewValue;
336 }
337
338 return $this->CharSet;
339 }
340
346 public static function LineEnding($NewValue = NULL)
347 {
348 if (!is_null($NewValue))
349 {
350 self::$LineEnding = $NewValue;
351 }
352
353 return self::$LineEnding;
354 }
355
368 public static function WrapHtmlAsNecessary(
369 $Html, $MaxLineLength=998, $LineEnding="\r\n")
370 {
371 # the regular expression used to find long lines
372 $LongLineRegExp = '/[^\r\n]{'.($MaxLineLength+1).',}/';
373
374 # find all lines that are too long
375 preg_match_all($LongLineRegExp, $Html, $Matches,
376 PREG_PATTERN_ORDER|PREG_OFFSET_CAPTURE);
377
378 # no changes are necessary
379 if (!count($Matches))
380 {
381 return $Html;
382 }
383
384 # go backwards so that the HTML can be edited in place without messing
385 # with the offsets
386 for ($i = count($Matches[0]) - 1; $i >= 0; $i--)
387 {
388 # extract the line text and its offset within the string
389 list($Line, $Offset) = $Matches[0][$i];
390
391 # first try to get the line under the limit without being too
392 # aggressive
393 $BetterLine = self::ConvertHtmlWhiteSpace($Line, FALSE, $LineEnding);
394 $WasAggressive = "No";
395
396 # if the line is still too long, be more aggressive with replacing
397 # horizontal whitespace
398 if (preg_match($LongLineRegExp, $BetterLine))
399 {
400 $BetterLine = self::ConvertHtmlWhiteSpace($Line, TRUE, $LineEnding);
401 $WasAggressive = "Yes";
402 }
403
404 # tack on an HTML comment stating that the line was wrapped and give
405 # some additional info
406 $BetterLine = $LineEnding."<!-- Line was wrapped. Aggressive: "
407 .$WasAggressive.", Max: ".$MaxLineLength.", Actual: "
408 .strlen($Line)." -->".$LineEnding.$BetterLine;
409
410 # replace the line within the HTML
411 $Html = substr_replace($Html, $BetterLine, $Offset, strlen($Line));
412 }
413
414 return $Html;
415 }
416
424 public static function TestLineEndings($Value, $LineEnding)
425 {
426 # the number of \r in the string
427 $NumCR = substr_count($Value, "\r");
428
429 # LF
430 if ($LineEnding == "\n")
431 {
432 return $NumCR === 0;
433 }
434
435 # the number of \n in the string
436 $NumLF = substr_count($Value, "\n");
437
438 # CR
439 if ($LineEnding == "\r")
440 {
441 return $NumLF === 0;
442 }
443
444 # the number of \r\n in the string
445 $NumCRLF = substr_count($Value, "\r\n");
446
447 # CRLF. also check CRLF to make sure CR and LF appear together and in
448 # the correct order
449 return $NumCR === $NumLF && $NumLF === $NumCRLF;
450 }
451
457 public static function ConvertHtmlToPlainText($Html)
458 {
459 # remove newlines
460 $Text = str_replace(array("\r", "\n"), "", $Html);
461
462 # convert HTML breaks to newlines
463 $Text = preg_replace('/<br\s*\/?>/', "\n", $Text);
464
465 # strip remaining tags
466 $Text = strip_tags($Text);
467
468 # convert HTML entities to their plain-text equivalents
469 $Text = html_entity_decode($Text);
470
471 # single quotes aren't always handled
472 $Text = str_replace('&#39;', "'", $Text);
473
474 # remove HTML entities that have no equivalents
475 $Text = preg_replace('/&(#[0-9]{1,6}|[a-zA-Z0-9]{1,6});/', "", $Text);
476
477 # return the plain text version
478 return $Text;
479 }
480 /*@(*/
482
489 public static function DeliveryMethod($NewValue = NULL)
490 {
491 if ($NewValue !== NULL)
492 {
493 self::$DeliveryMethod = $NewValue;
494 }
495 return self::$DeliveryMethod;
496 }
498 const METHOD_PHPMAIL = 1;
500 const METHOD_SMTP = 2;
501
507 public static function Server($NewValue = NULL)
508 {
509 if ($NewValue !== NULL) { self::$Server = $NewValue; }
510 return self::$Server;
511 }
512
518 public static function Port($NewValue = NULL)
519 {
520 if ($NewValue !== NULL) { self::$Port = $NewValue; }
521 return self::$Port;
522 }
523
529 public static function UserName($NewValue = NULL)
530 {
531 if ($NewValue !== NULL) { self::$UserName = $NewValue; }
532 return self::$UserName;
533 }
534
540 public static function Password($NewValue = NULL)
541 {
542 if ($NewValue !== NULL) { self::$Password = $NewValue; }
543 return self::$Password;
544 }
545
551 public static function UseAuthentication($NewValue = NULL)
552 {
553 if ($NewValue !== NULL) { self::$UseAuthentication = $NewValue; }
554 return self::$UseAuthentication;
555 }
556
564 public static function DeliverySettings($NewSettings = NULL)
565 {
566 if ($NewSettings !== NULL)
567 {
568 $Settings = unserialize($NewSettings);
569 self::$DeliveryMethod = $Settings["DeliveryMethod"];
570 self::$Server = $Settings["Server"];
571 self::$Port = $Settings["Port"];
572 self::$UserName = $Settings["UserName"];
573 self::$Password = $Settings["Password"];
574 self::$UseAuthentication = $Settings["UseAuthentication"];
575 }
576 else
577 {
578 $Settings["DeliveryMethod"] = self::$DeliveryMethod;
579 $Settings["Server"] = self::$Server;
580 $Settings["Port"] = self::$Port;
581 $Settings["UserName"] = self::$UserName;
582 $Settings["Password"] = self::$Password;
583 $Settings["UseAuthentication"] = self::$UseAuthentication;
584 }
585 return serialize($Settings);
586 }
587
596 public static function DeliverySettingsOkay()
597 {
598 # start out with error list clear
599 self::$DeliverySettingErrorList = array();
600
601 # test based on delivery method
602 switch (self::$DeliveryMethod)
603 {
604 case self::METHOD_PHPMAIL:
605 # always report success
606 $SettingsOkay = TRUE;
607 break;
608
609 case self::METHOD_SMTP:
610 # set up PHPMailer for test
611 $PMail = new PHPMailer(TRUE);
612 $PMail->IsSMTP();
613 $PMail->SMTPAuth = self::$UseAuthentication;
614 $PMail->Host = self::$Server;
615 $PMail->Port = self::$Port;
616 $PMail->Username = self::$UserName;
617 $PMail->Password = self::$Password;
618
619 # test settings
620 try
621 {
622 $SettingsOkay = $PMail->SmtpConnect();
623 }
624 # if test failed
625 catch (phpmailerException $Except)
626 {
627 # translate PHPMailer error message to possibly bad settings
628 switch ($Except->getMessage())
629 {
630 case 'SMTP Error: Could not authenticate.':
631 self::$DeliverySettingErrorList = array(
632 "UseAuthentication",
633 "UserName",
634 "Password",
635 );
636 break;
637
638 case 'SMTP Error: Could not connect to SMTP host.':
639 self::$DeliverySettingErrorList = array(
640 "Server",
641 "Port",
642 );
643 break;
644
645 case 'Language string failed to load: tls':
646 self::$DeliverySettingErrorList = array("TLS");
647 break;
648
649 default:
650 self::$DeliverySettingErrorList = array("UNKNOWN");
651 break;
652 }
653
654 # make sure failure is reported
655 $SettingsOkay = FALSE;
656 }
657 break;
658 }
659
660 # report result to caller
661 return $SettingsOkay;
662 }
663
668 public static function DeliverySettingErrors()
669 {
670 return self::$DeliverySettingErrorList;
671 }
672
673
674 # ---- PRIVATE INTERFACE -------------------------------------------------
675
676 private $AlternateBody = "";
677 private $BCC = array();
678 private $Body = "";
679 private $CC = array();
680 private $CharSet;
681 private $From = "";
682 private $Headers = array();
683 private $ReplyTo = "";
684 private $Subject = "";
685 private $To = array();
686 private $Whitelist = array();
687 private $LogData = NULL;
688
689 private static $DefaultFrom = "";
690 private static $DeliveryMethod = self::METHOD_PHPMAIL;
691 private static $DeliverySettingErrorList = array();
692 private static $LineEnding = "\r\n";
693 private static $Password = "";
694 private static $Port = 25;
695 private static $RecipientWhitelist = array();
696 private static $Server;
697 private static $UseAuthentication = FALSE;
698 private static $UserName = "";
699 private static $LoggingFunc = NULL;
700
705 private function SendViaPhpMailFunc()
706 {
707 # Contrary to the PHP documentation, line endings for PHP's
708 # mail function should be the system native line endings.
709 #
710 # see https://bugs.php.net/bug.php?id=15841 for details
711
712 # Use the system line endings
713 $LE = PHP_EOL;
714
715 # build basic headers list
716 $From = strlen($this->From) ? $this->From : self::$DefaultFrom;
717 $Headers = "From: ".self::CleanHeaderValue($From).$LE;
718 $Headers .= $this->BuildAddresseeLine("Cc", $this->CC);
719 $Headers .= $this->BuildAddresseeLine("Bcc", $this->BCC);
720 $Headers .= "Reply-To: ".self::CleanHeaderValue(
721 strlen($this->ReplyTo) ? $this->ReplyTo : $this->From).$LE;
722
723 # add additional headers
724 foreach ($this->Headers as $ExtraHeader)
725 {
726 $Headers .= $ExtraHeader.$LE;
727 }
728
729 # build recipient list
730 $To = "";
731 $Separator = "";
732 foreach ($this->To as $Recipient)
733 {
734 $To .= $Separator.$Recipient;
735 $Separator = ", ";
736 }
737
738 # normalize message body line endings
739 $Body = $this->NormalizeLineEndings($this->Body, $LE);
740
741 # send message
742 $Result = mail($To, $this->Subject, $Body, $Headers);
743
744 # report to caller whether attempt to send succeeded
745 return $Result;
746 }
747
753 private function SendViaPhpMailerLib()
754 {
755 # create and initialize PHPMailer
756 $PMail = new PHPMailer();
757 $PMail->LE = self::$LineEnding;
758 $PMail->Subject = $this->Subject;
759 $PMail->Body = $this->Body;
760 $PMail->IsHTML(FALSE);
761
762 # default values for the sender's name and address
763 $Name = "";
764 $Address = $this->From;
765
766 # if the address contains a name and address, they need to extracted
767 # because PHPMailer requires that they are set as two different
768 # parameters
769 if (preg_match("/ </", $this->From))
770 {
771 $Pieces = explode(" ", $this->From);
772 $Address = array_pop($Pieces);
773 $Address = preg_replace("/[<>]+/", "", $Address);
774 $Name = trim(implode($Pieces, " "));
775 }
776
777 # add the sender
778 $PMail->SetFrom($Address, $Name);
779
780 # add each recipient
781 foreach ($this->To as $Recipient)
782 {
783 $PMail->AddAddress($Recipient);
784 }
785
786 # add any extra header lines
787 foreach ($this->Headers as $ExtraHeader)
788 {
789 $PMail->AddCustomHeader($ExtraHeader);
790 }
791
792 # add the charset if it's set
793 if (isset($this->CharSet))
794 {
795 $PMail->CharSet = strtolower($this->CharSet);
796 }
797
798 # add the alternate plain-text body if it's set
799 if ($this->HasAlternateBody())
800 {
801 $PMail->AltBody = $this->AlternateBody;
802 }
803
804 # set up SMTP if necessary
805 if (self::$DeliveryMethod == self::METHOD_SMTP)
806 {
807 $PMail->IsSMTP();
808 $PMail->SMTPAuth = self::$UseAuthentication;
809 $PMail->Host = self::$Server;
810 $PMail->Port = self::$Port;
811 $PMail->Username = self::$UserName;
812 $PMail->Password = self::$Password;
813 }
814
815 # send message
816 $Result = $PMail->Send();
817
818 # report to caller whether attempt to send succeeded
819 return $Result;
820 }
821
826 private function SendViaSmtp()
827 {
828 # send via PHPMailer because it's capable of handling SMTP
829 return $this->SendViaPhpMailerLib();
830 }
831
838 private function BuildAddresseeLine($Label, $Recipients)
839 {
840 $Line = "";
841 if (count($Recipients))
842 {
843 $Line .= $Label.": ";
844 $Separator = "";
845 foreach ($Recipients as $Recipient)
846 {
847 $Line .= $Separator.self::CleanHeaderValue($Recipient);
848 $Separator = ", ";
849 }
850 $Line .= self::$LineEnding;
851 }
852 return $Line;
853 }
854
859 private function HasAlternateBody()
860 {
861 return isset($this->AlternateBody) && strlen(trim($this->AlternateBody)) > 0;
862 }
863
869 private static function CleanHeaderValue($Value)
870 {
871 # (regular expression taken from sanitizeHeaders() function in
872 # Mail PEAR package)
873 return preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i',
874 "", $Value);
875 }
876
883 private static function NormalizeLineEndings($Value, $LineEnding)
884 {
885 return preg_replace('/\r\n|\r|\n/', $LineEnding, $Value);
886 }
887
902 protected static function ConvertHtmlWhiteSpace(
903 $Html, $Aggressive=FALSE, $LineEnding="\r\n")
904 {
905 $HtmlLength = strlen($Html);
906
907 # tags that should have their inner HTML left alone
908 $IgnoredTags = array('script', 'style', 'textarea', 'title');
909
910 # values for determining context
911 $InTag = FALSE;
912 $InClosingTag = FALSE;
913 $InIgnoredTag = FALSE;
914 $InAttribute = FALSE;
915 $TagName = NULL;
916 $IgnoredTagName = NULL;
917 $AttributeDelimiter = NULL;
918
919 # loop through each character of the string
920 for ($i = 0; $i < $HtmlLength; $i++)
921 {
922 $Char = $Html{$i};
923
924 # beginning of a tag
925 if ($Char == "<" && !$InTag)
926 {
927 $InTag = TRUE;
928 $InAttribute = FALSE;
929 $AttributeDelimiter = NULL;
930
931 # do some lookaheads to get the tag name and to see if the tag
932 # is a closing tag
933 list($InClosingTag, $TagName) = self::GetTagInfo($Html, $i);
934
935 # moving into an ignored tag
936 if (!$InClosingTag && in_array($TagName, $IgnoredTags))
937 {
938 $InIgnoredTag = TRUE;
939 $IgnoredTagName = $TagName;
940 }
941
942 continue;
943 }
944
945 # end of a tag
946 if ($Char == ">" && $InTag && !$InAttribute)
947 {
948 # moving out of an ignored tag
949 if ($InClosingTag && $InIgnoredTag && $TagName == $IgnoredTagName)
950 {
951 $InIgnoredTag = FALSE;
952 $IgnoredTagName = NULL;
953 }
954
955 $InTag = FALSE;
956 $InClosingTag = FALSE;
957 $InAttribute = FALSE;
958 $TagName = NULL;
959 $AttributeDelimiter = NULL;
960
961 continue;
962 }
963
964 # attribute delimiter characters
965 if ($Char == "'" || $Char == '"')
966 {
967 # beginning of an attribute
968 if (!$InAttribute)
969 {
970 $InAttribute = TRUE;
971 $AttributeDelimiter = $Char;
972 continue;
973 }
974
975 # end of the attribute
976 if ($InAttribute && $Char == $AttributeDelimiter)
977 {
978 $InAttribute = FALSE;
979 $AttributeDelimiter = NULL;
980 continue;
981 }
982 }
983
984 # whitespace inside of a tag but outside of an attribute can be
985 # safely converted to a newline
986 if ($InTag && !$InAttribute && preg_match('/\s/', $Char))
987 {
988 $Html{$i} = $LineEnding;
989 continue;
990 }
991
992 # whitespace outside of a tag can be safely converted to a newline
993 # when not in one of the ignored tags, but only do so if horizontal
994 # space is at a premium because it can make the resulting HTML
995 # difficult to read
996 if ($Aggressive && !$InTag && !$InIgnoredTag && preg_match('/\s/', $Char))
997 {
998 $Html{$i} = $LineEnding;
999 continue;
1000 }
1001 }
1002
1003 return $Html;
1004 }
1005
1014 protected static function GetTagInfo($Html, $TagBegin)
1015 {
1016 $HtmlLength = strlen($Html);
1017
1018 # default return values
1019 $InClosingTag = FALSE;
1020 $TagName = NULL;
1021
1022 # if at the end of the string and lookaheads aren't possible
1023 if ($TagBegin + 1 >= $HtmlLength)
1024 {
1025 return array($InClosingTag, $TagName);
1026 }
1027
1028 # do a lookahead for whether it's a closing tag
1029 if ($Html{$TagBegin+1} == "/")
1030 {
1031 $InClosingTag = TRUE;
1032 }
1033
1034 # determine whether to offset by one or two to get the tag name
1035 $TagStart = $InClosingTag ? $TagBegin + 2 : $TagBegin + 1;
1036
1037 # do a lookahead for the tag name
1038 for ($i = $TagStart; $i < $HtmlLength; $i++)
1039 {
1040 $Char = $Html{$i};
1041
1042 # stop getting the tag name if whitespace is found and something is
1043 # available for the tag name
1044 if (strlen($TagName) && preg_match('/[\r\n\s]/', $Char))
1045 {
1046 break;
1047 }
1048
1049 # stop getting the tag name if the character is >
1050 if ($Char == ">")
1051 {
1052 break;
1053 }
1054
1055 $TagName .= $Char;
1056 }
1057
1058 # comment "tag"
1059 if (substr($TagName, 0, 3) == "!--")
1060 {
1061 return array($InClosingTag, "!--");
1062 }
1063
1064 # remove characters that aren't part of a valid tag name
1065 $TagName = preg_replace('/[^a-zA-Z0-9]/', '', $TagName);
1066
1067 return array($InClosingTag, $TagName);
1068 }
1069 }
Email\From
From($NewAddress=NULL, $NewName=NULL)
Get/set message sender.
Definition: Email.php:189
Email\RegisterLoggingFunction
static RegisterLoggingFunction($NewValue)
Register a logging callback.
Definition: Email.php:121
Email\Server
static Server($NewValue=NULL)
Get/set server for mail delivery.
Definition: Email.php:507
Email\DeliveryMethod
static DeliveryMethod($NewValue=NULL)
Get/set mail delivery method.
Definition: Email.php:489
Email\WrapHtmlAsNecessary
static WrapHtmlAsNecessary($Html, $MaxLineLength=998, $LineEnding="\r\n")
Wrap HTML in an e-mail as necessary to get its lines less than some max length.
Definition: Email.php:368
Email\To
To($NewValue=NULL)
Get/set message recipient(s).
Definition: Email.php:252
Email\DeliverySettings
static DeliverySettings($NewSettings=NULL)
Get/set serialized (opaque text) version of delivery settings.
Definition: Email.php:564
Email\ReplyTo
ReplyTo($NewAddress=NULL, $NewName=NULL)
Get/set message "Reply-To" address.
Definition: Email.php:227
Email\ToWhitelist
static ToWhitelist($NewValue=NULL)
Set whitelist of acceptable recipient addresses.
Definition: Email.php:107
Email\DeliverySettingsOkay
static DeliverySettingsOkay()
Test delivery settings and report their validity.
Definition: Email.php:596
Email\LineEnding
static LineEnding($NewValue=NULL)
Specify the character sequence that should be used to end lines.
Definition: Email.php:346
Email\DeliverySettingErrors
static DeliverySettingErrors()
Return array with list of delivery setting errors (if any).
Definition: Email.php:668
Email\CharSet
CharSet($NewValue=NULL)
Specify a character encoding for the message.
Definition: Email.php:330
Email
Electronic mail message.
Definition: Email.php:14
Email\DefaultFrom
static DefaultFrom($NewValue=NULL)
Get/set default "From" address.
Definition: Email.php:213
Email\GetTagInfo
static GetTagInfo($Html, $TagBegin)
Get the tag name and whether it&#39;s a closing tag from a tag that begins at a specific offset within so...
Definition: Email.php:1014
Email\Send
Send()
Mail the message.
Definition: Email.php:28
StdLib\substr
static substr()
Multibyte-aware (if supported in PHP) version of substr().
Definition: StdLib.php:523
PHP
PHP
Definition: RSSClient--Test.php:12
Email\AddHeaders
AddHeaders($NewHeaders)
Specify additional message headers to be included.
Definition: Email.php:318
Email\AddLogData
AddLogData($LogData)
Provide additional data that should be included when a message is logged.
Definition: Email.php:136
Email\METHOD_PHPMAIL
const METHOD_PHPMAIL
Deliver using PHP&#39;s internal mail() mechanism.
Definition: Email.php:498
Email\BCC
BCC($NewValue=NULL)
Get/set message BCC list.
Definition: Email.php:298
Email\Body
Body($NewValue=NULL)
Get/set message body.
Definition: Email.php:148
Email\Port
static Port($NewValue=NULL)
Get/set port number for mail delivery.
Definition: Email.php:518
Email\UserName
static UserName($NewValue=NULL)
Get/set user name for mail delivery.
Definition: Email.php:529
Email\AlternateBody
AlternateBody($NewValue=NULL)
Get/set the plain-text alternative to the body.
Definition: Email.php:159
Email\Subject
Subject($NewValue=NULL)
Get/set message subject.
Definition: Email.php:175
Email\METHOD_SMTP
const METHOD_SMTP
Deliver using SMTP.
Definition: Email.php:500
Email\Password
static Password($NewValue=NULL)
Get/set password for mail delivery.
Definition: Email.php:540
Email\ConvertHtmlToPlainText
static ConvertHtmlToPlainText($Html)
Try as best as possible to convert HTML to plain text.
Definition: Email.php:457
Email\UseAuthentication
static UseAuthentication($NewValue=NULL)
Get/set whether to use authentication for mail delivery.
Definition: Email.php:551
Email\TestLineEndings
static TestLineEndings($Value, $LineEnding)
Test the line endings in a value to see if they all match the given line ending.
Definition: Email.php:424
Email\CC
CC($NewValue=NULL)
Get/set message CC list.
Definition: Email.php:275
Email\ConvertHtmlWhiteSpace
static ConvertHtmlWhiteSpace($Html, $Aggressive=FALSE, $LineEnding="\r\n")
Convert horizontal white space with no semantic value to vertical white space when possible...
Definition: Email.php:902