3require_once(
'AWLUtilities.php');
12 public static $crlf =
"\r\n";
14 function __construct( $content, $type=
'text/plain', $otherHeaders=array() ) {
15 $this->content = $content;
17 $this->otherHeaders = $otherHeaders;
21 $result =
'Content-Type: '.$this->type.self::$crlf;
23 foreach( $this->otherHeaders AS $header => $value ) {
24 $result .= $header.
': '.$value.self::$crlf;
25 if ( $header ==
'Content-Transfer-Encoding' ) $encoded =
true;
29 return $result . self::$crlf . $this->content;
31 return $result .
'Content-Transfer-Encoding: base64' . self::$crlf
33 . base64_encode($this->content);
43 function __construct() {
44 $this->parts = array();
45 $this->boundary = uuid();
49 $args = func_get_args();
50 if ( is_string($args[0]) ) {
51 $newPart =
new SinglePart( $args[0], (isset($args[1])?$args[1]:
'text/plain'), (isset($args[2])?$args[2]:array()));
56 $this->parts[] = $newPart;
62 function getMimeHeaders() {
63 return 'MIME-Version: 1.0' . SinglePart::$crlf
64 .
'Content-Type: multipart/mixed; boundary='.$this->boundary . SinglePart::$crlf ;
67 function getMimeParts() {
68 $result =
'--' . $this->boundary . SinglePart::$crlf;
69 foreach( $this->parts AS $part ) {
70 $result .= $part->render() . SinglePart::$crlf .
'--' . $this->boundary;
72 $result .=
'--' . SinglePart::$crlf;