Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezmail.php
Go to the documentation of this file.
1 <?php
2 //
3 // $Id: ezmail.php,v 1.44.2.7 2002/06/10 16:41:45 fh Exp $
59 class eZMail
60 {
61 public $References;
62 const REGEXP = '(((\"[^\"\f\n\r\t\v\b]+\")|([A-Za-z0-9_\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[A-Za-z0-9_\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]{2,})))';
63
64 public function __construct()
65 {
66 $this->Mail = new ezpMail();
67
68 $this->ReceiverElements = array();
69 $this->From = false;
70 $this->CcElements = array();
71 $this->BccElements = array();
72 $this->ReplyTo = false;
73 $this->Subject = false;
74 $this->BodyText = false;
75 $this->ExtraHeaders = array();
76 $this->TextCodec = false;
77 $this->MessageID = false;
78
79 // Sets some default values
80 $version = eZPublishSDK::version();
81
82 $this->MIMEVersion = '1.0';
83 $this->ContentType = array( 'type' => 'text/plain',
84 'charset' => $this->usedCharset(),
85 'transfer-encoding' => '8bit',
86 'disposition' => 'inline',
87 'boundary' => false );
88 $this->UserAgent = "eZ Publish, Version $version";
89
90 $ini = eZINI::instance();
91
92 if ( $ini->hasVariable( 'MailSettings', 'ContentType' ) )
93 $this->setContentType( $ini->variable( 'MailSettings', 'ContentType' ) );
94 }
95
101 function receiverEmailText( $convert = true )
102 {
103 /*
104 $addresses = array();
105 foreach ( $this->Mail->to as $address )
106 {
107 $addresses[] = $address->email;
108 }
109 return implode( ', ', $addresses );
110 */
111 return $this->composeEmailItems( $this->ReceiverElements, true, 'email', $convert );
112 }
113
119 function receiverText( $convert = true )
120 {
121 // return ezcMailTools::composeEmailAddresses( $this->Mail->to );
122 return $this->composeEmailItems( $this->ReceiverElements, true, false, $convert );
123 }
124
130 function ccReceiverTextList( $convert = true )
131 {
132 /*
133 $addresses = array();
134 foreach ( $this->Mail->cc as $address )
135 {
136 $addresses[] = $address->email;
137 }
138 return implode( ', ', $addresses );
139 */
140 return $this->composeEmailItems( $this->CcElements, false, 'email', $convert );
141 }
142
146 function bccReceiverTextList( $convert = true )
147 {
148 /*
149 $addresses = array();
150 foreach ( $this->Mail->bcc as $address )
151 {
152 $addresses[] = $address->email;
153 }
154 return implode( ', ', $addresses );
155 */
156 return $this->composeEmailItems( $this->BccElements, false, 'email', $convert );
157 }
158
164 function receiverTextList( $convert = true )
165 {
166 /*
167 $addresses = array();
168 foreach ( $this->Mail->to as $address )
169 {
170 $addresses[] = $address->email;
171 }
172 return implode( ', ', $addresses );
173 */
174 return $this->composeEmailItems( $this->ReceiverElements, false, 'email', $convert );
175 }
176
182 function receiverElements()
183 {
184 /*
185 $addresses = array();
186 foreach ( $this->Mail->to as $address )
187 {
188 $addresses[] = array( 'name' => $address->name, 'email' => $address->email );
189 }
190 return $addresses;
191 */
192 return $this->ReceiverElements;
193 }
194
200 function ccElements()
201 {
202 /*
203 $addresses = array();
204 foreach ( $this->Mail->cc as $address )
205 {
206 $addresses[] = array( 'name' => $address->name, 'email' => $address->email );
207 }
208 return $addresses;
209 */
210 return $this->CcElements;
211 }
212
218 function bccElements()
219 {
220 /*
221 $addresses = array();
222 foreach ( $this->Mail->bcc as $address )
223 {
224 $addresses[] = array( 'name' => $address->name, 'email' => $address->email );
225 }
226 return $addresses;
227 */
228 return $this->BccElements;
229 }
230
231
237 function replyTo( $convert = true )
238 {
239 // return $this->Mail->getHeader( 'Reply-To' );
240 if ( !$convert )
241 return $this->ReplyTo;
242 return $this->convertHeaderText( $this->ReplyTo );
243 }
244
250 function sender( $convert = true )
251 {
252 // return $this->Mail->from;
253 if ( !$convert )
254 return $this->From;
255
256 if ( is_array( $this->From ) )
257 {
258 $convertedSender = $this->From;
259 if ( $this->From['name'] )
260 {
261 $convertedSender['name'] = $this->convertHeaderText( $this->From['name'] );
262 }
263 return $convertedSender;
264 }
265 else if ( is_string( $this->From ) )
266 {
267 return $this->convertHeaderText( $this->From );
268 }
269
270 return $this->From;
271 }
272
278 function senderText( $convert = true )
279 {
280 // return ezcMailTools::composeEmailAddress( $this->Mail->from );
281 $text = eZMail::composeEmailName( $this->From );
282 if ( !$convert )
283 return $text;
284 return $this->convertHeaderText( $text );
285 }
286
293 function mimeVersion()
294 {
295 // return $this->Mail->getHeader( 'MIME-Version' );
296 return $this->MIMEVersion;
297 }
298
304 function contentType()
305 {
306 // return $this->Mail->getHeader( 'Content-Type' );
307 return $this->ContentType['type'];
308 }
309
316 function contentCharset()
317 {
318 return $this->ContentType['charset'];
319 }
320
326 function contentTransferEncoding()
327 {
328 // return $this->Mail->getHeader( 'Content-Transfer-Encoding' );
329 return $this->ContentType['transfer-encoding'];
330 }
331
337 function contentDisposition()
338 {
339 // return $this->Mail->getHeader( 'Content-Disposition' );
340 // return $this->Mail->contentDisposition->disposition;
341 return $this->ContentType['disposition'];
342 }
343
349 function userAgent( $convert = true )
350 {
351 // return $this->Mail->getHeader( 'User-Agent' );
352 if ( !$convert )
353 return $this->UserAgent;
354 return $this->convertHeaderText( $this->UserAgent );
355 }
356
362 function setMIMEVersion( $version )
363 {
364 $this->Mail->setHeader( 'MIME-Version', $version );
365 $this->MIMEVersion = $version;
366 }
367
374 function setContentType( $type = false, $charset = false,
375 $transferEncoding = false, $disposition = false, $boundary = false )
376 {
377 if ( $type )
378 {
379 $this->ContentType['type'] = $type;
380 }
381 if ( $charset )
382 $this->ContentType['charset'] = $charset;
383 if ( $transferEncoding )
384 $this->ContentType['transfer-encoding'] = $transferEncoding;
385 if ( $disposition )
386 $this->ContentType['disposition'] = $disposition;
387 if ( $boundary )
388 $this->ContentType['boundary'] = $boundary;
389
390 // if the body was already defined
391 if ( $this->Mail->body instanceof ezcMailText )
392 {
393 // if the content-type is in the form of e.g. 'text/plain'
394 if ( strpos( $this->ContentType['type'] ,'/' ) !== false )
395 {
396 list( $type, $subType ) = explode( '/', $this->ContentType['type'] );
397 $this->Mail->body->subType = $subType;
398 }
399 }
400 }
401
407 function setUserAgent( $agent )
408 {
409 $this->Mail->setHeader( 'User-Agent', $agent );
410 $this->UserAgent = $agent;
411 }
412
418 function setReceiverElements( $toElements )
419 {
420 $this->Mail->to = array();
421 foreach ( $toElements as $address )
422 {
423 $name = isset( $address['name'] ) ? $address['name'] : false;
424 $this->Mail->addTo( new ezcMailAddress( $address['email'], $name, $this->usedCharset() ) );
425 }
426 $this->ReceiverElements = $toElements;
427 }
428
436 function setReceiver( $email, $name = false )
437 {
438 $this->Mail->to = array( new ezcMailAddress( $email, $name, $this->usedCharset() ) );
439 $this->ReceiverElements = array( array( 'name' => $name,
440 'email' => $email ) );
441 }
442
450 function setReceiverText( $text )
451 {
452 $this->extractEmail( $text, $email, $name );
453 $this->Mail->to = array( new ezcMailAddress( $email, $name, $this->usedCharset() ) );
454 $this->ReceiverElements = array( array( 'name' => $name,
455 'email' => $email ) );
456 }
457
463 function addReceiver( $email, $name = false )
464 {
465 $this->Mail->addTo( new ezcMailAddress( $email, $name, $this->usedCharset() ) );
466 $this->ReceiverElements[] = array( 'name' => $name,
467 'email' => $email );
468 }
469
475 function setReplyTo( $email, $name = false )
476 {
477 $this->Mail->setHeader( 'Reply-To', new ezcMailAddress( $email, $name, $this->usedCharset() ) );
478 $this->ReplyTo = array( 'name' => $name,
479 'email' => $email );
480 }
481
487 function setSender( $email, $name = false )
488 {
489 $this->Mail->from = new ezcMailAddress( $email, $name, $this->usedCharset() );
490 $this->From = array( 'name' => $name,
491 'email' => $email );
492 }
493
499 function setSenderText( $text )
500 {
501 $this->extractEmail( $text, $email, $name );
502 $this->Mail->from = new ezcMailAddress( $email, $name, $this->usedCharset() );
503 $this->From = array( 'name' => $name,
504 'email' => $email );
505 }
506
512 function setCcElements( $newCc )
513 {
514 $this->Mail->cc = array();
515 foreach ( $newCc as $address )
516 {
517 $name = isset( $address['name'] ) ? $address['name'] : false;
518 $this->Mail->addCc( new ezcMailAddress( $address['email'], $name, $this->usedCharset() ) );
519 }
520 $this->CcElements = $newCc;
521 }
522
528 function addCc( $email, $name = false )
529 {
530 $this->Mail->addCc( new ezcMailAddress( $email, $name, $this->usedCharset() ) );
531 $this->CcElements[] = array( 'name' => $name,
532 'email' => $email );
533 }
534
540 function setBccElements( $newBcc )
541 {
542 $this->Mail->bcc = array();
543 foreach ( $newBcc as $address )
544 {
545 $name = isset( $address['name'] ) ? $address['name'] : false;
546 $this->Mail->addBcc( new ezcMailAddress( $address['email'], $name, $this->usedCharset() ) );
547 }
548 $this->BccElements = $newBcc;
549 }
550
556 function addBcc( $email, $name = false )
557 {
558 $this->Mail->addBcc( new ezcMailAddress( $email, $name, $this->usedCharset() ) );
559 $this->BccElements[] = array( 'name' => $name,
560 'email' => $email );
561 }
562
568 function extraHeaders()
569 {
570 return $this->ExtraHeaders;
571 }
572
578 function addExtraHeader( $headerName, $headerValue )
579 {
580 $this->Mail->setHeader( $headerName, $headerValue );
581 return $this->ExtraHeaders[] = array( 'name' => $headerName,
582 'content' => $headerValue );
583 }
584
590 function setExtraHeader( $headerName, $headerValue )
591 {
592 $this->Mail->setHeader( $headerName, $headerValue );
593 for ( $i = 0; $i < count( $this->ExtraHeaders ); ++$i )
594 {
595 $extraHeader =& $this->ExtraHeaders[$i];
596 if ( isset( $extraHeader['name'] ) and
597 $extraHeader['name'] == $headerName )
598 {
599 $extraHeader = array( 'name' => $headerName,
600 'content' => $headerValue );
601 return true;
602 }
603 }
604 $this->addExtraHeader( $headerName, $headerValue );
605 }
606
612 function setExtraHeaders( $headers )
613 {
614 $this->Mail->setHeaders( $headers );
615 return $this->ExtraHeaders = $headers;
616 }
617
624 function messageID()
625 {
626 // return $this->Mail->messageId;
627 return $this->MessageID;
628 }
629
635 function setMessageID( $newMessageID )
636 {
637 $this->Mail->messageId = $newMessageID;
638 $this->MessageID = $newMessageID;
639 }
640
646 function references()
647 {
648 return $this->References;
649 }
650
656 function setReferences( $newReference )
657 {
658 $this->References = $newReference;
659 }
660
666 function subject( $convert = true )
667 {
668 // return $this->Mail->subject;
669 if ( !$convert )
670 return $this->Subject;
671 return $this->convertHeaderText( $this->Subject );
672 }
673
679 function setSubject( $newSubject )
680 {
681 $this->Mail->subject = trim( $newSubject );
682 $this->Mail->subjectCharset = $this->usedCharset();
683 $this->Subject = trim( $newSubject );
684 }
685
691 function body( $convert = true )
692 {
693 // return $this->Mail->body;
694 if ( !$convert )
695 return $this->BodyText;
696 return $this->convertText( $this->BodyText );
697 }
698
704 function setBody( $newBody )
705 {
706 // if it's an object (e.g. ezcMailText) then set it directly, otherwise
707 // create a new ezcMailText object to contain the body text
708 if ( $newBody instanceof ezcMailPart )
709 {
710 $this->Mail->body = $newBody;
711 }
712 else
713 {
714 $this->Mail->body = new ezcMailText( $newBody, $this->usedCharset() );
715
716 // if the content-type is in the form of 'text/plain'
717 if ( strpos( $this->ContentType['type'] ,'/' ) !== false )
718 {
719 list( $type, $subType ) = explode( '/', $this->ContentType['type'] );
720 $this->Mail->body->subType = $subType;
721 }
722 }
723 $newBody = preg_replace( "/\r\n|\r|\n/", eZMail::lineSeparator(), $newBody );
724 $this->BodyText = $newBody;
725 }
726
733 static function &splitList( $emails )
734 {
735 $emails = preg_split( "/[,;]/", $emails );
736 return $emails;
737 }
738
747 static function validate( $address )
748 {
749 return preg_match( '/^' . eZMail::REGEXP . '$/', $address );
750 }
751
757 static function extractEmail( $text, &$email, &$name )
758 {
759 if ( preg_match( "/([^<]+)<" . eZMail::REGEXP . ">/", $text, $matches ) )
760 {
761 $email = $matches[2];
762 $name = trim( $matches[1], '" ' );
763 }
764 else
765 {
766 $email = $text;
767 $name = false;
768 }
769 }
770
779 static function stripEmail( $address )
780 {
781 $res = preg_match( "/" . eZMail::REGEXP . "/", $address, $email );
782
783 if ( $res )
784 return $email[0];
785 else
786 return 0;
787 }
788
795 static function blankNewlines( $text )
796 {
797 return preg_replace( "/\r\n|\r|\n/", ' ', $text );
798 }
799
807 static function contentString( $content )
808 {
809 if ( is_array( $content ) )
810 return implode( '; ', $content );
811 else
812 return (string)$content;
813 }
814
822 function composeEmailName( $item, $key = false, $convert = true )
823 {
824 if ( $key !== false and
825 isset( $item[$key] ) )
826 return $item[$key];
827 if ( $item['name'] )
828 {
829 if ( $convert )
830 $item['name'] = $this->convertHeaderText( $item['name'] );
831 $text = $item['name'] . ' <' . $item['email'] . '>';
832 }
833 else
834 $text = $item['email'];
835 return $text;
836 }
837
844 function composeEmailItems( $items, $join = true, $key = false, $convert = true )
845 {
846 $textElements = array();
847 foreach ( $items as $item )
848 {
849 $textElements[] = eZMail::composeEmailName( $item, $key, $convert );
850 }
851
852 if ( $join )
853 $text = implode( ', ', $textElements );
854 else
855 $text = $textElements;
856
857 return $text;
858 }
859
870 function headers( $parameters = array() )
871 {
872 $parameters = array_merge( array( 'exclude-headers' => false ),
873 $parameters );
874 $excludeHeaders = array();
875 if ( $parameters['exclude-headers'] )
876 {
877 foreach ( $parameters['exclude-headers'] as $excludeHeader )
878 {
879 $excludeHeaders[] = strtolower( $excludeHeader );
880 }
881 }
882 $headers = array();
883 $headerNames = array();
884 if ( !in_array( 'to', $excludeHeaders ) )
885 {
886 $toHeaderContent = count( $this->ReceiverElements ) > 0 ? $this->composeEmailItems( $this->ReceiverElements ) : 'undisclosed-recipients:;';
887 $headers[] = array( 'name' => 'To',
888 'content' => $toHeaderContent );
889 $headerNames[] = 'to';
890 }
891 if ( !in_array( 'date', $excludeHeaders ) )
892 {
893 $headers[] = array( 'name' => 'Date',
894 'content' => date( 'r' ) );
895 $headerNames[] = 'date';
896 }
897 if ( $this->Subject !== false and
898 !in_array( 'subject', $excludeHeaders ) )
899 {
900 $headers[] = array( 'name' => 'Subject',
901 'content' => $this->subject() );
902 $headerNames[] = 'subject';
903 }
904 if ( $this->From !== false and
905 !in_array( 'from', $excludeHeaders ) )
906 {
907 $headers[] = array( 'name' => 'From',
908 'content' => $this->composeEmailName( $this->From ) );
909 $headerNames[] = 'from';
910 }
911 if ( count( $this->CcElements ) > 0 and
912 !in_array( 'cc', $excludeHeaders ) )
913 {
914 $headers[] = array( 'name' => 'Cc',
915 'content' => $this->composeEmailItems( $this->CcElements ) );
916 $headerNames[] = 'cc';
917 }
918 if ( count( $this->BccElements ) > 0 and
919 !in_array( 'bcc', $excludeHeaders ) )
920 {
921 $headers[] = array( 'name' => 'Bcc',
922 'content' => $this->composeEmailItems( $this->BccElements ) );
923 $headerNames[] = 'bcc';
924 }
925 if ( $this->ReplyTo !== false and
926 !in_array( 'reply-to', $excludeHeaders ) )
927 {
928 $headers[] = array( 'name' => 'Reply-To',
929 'content' => $this->composeEmailName( $this->ReplyTo ) );
930 $headerNames[] = 'reply-to';
931 }
932 if ( !in_array( 'mime-version', $excludeHeaders ) )
933 {
934 $headers[] = array( 'name' => 'MIME-Version',
935 'content' => $this->MIMEVersion );
936 $headerNames[] = 'mime-version';
937 }
938 if ( !in_array( 'content-type', $excludeHeaders ) )
939 {
940 $charset = $this->usedCharset();
941 if ( $this->ContentType['boundary'] )
942 {
943 $headers[] = array( 'name' => 'Content-Type',
944 'content' => array( $this->ContentType['type'], 'charset='. $charset, 'boundary="'. $this->ContentType['boundary'] . '"' ) );
945 }
946 else
947 {
948 $headers[] = array( 'name' => 'Content-Type',
949 'content' => array( $this->ContentType['type'], 'charset='. $charset ) );
950 }
951 $headerNames[] = 'content-type';
952 }
953 if ( !in_array( 'content-transfer-encoding', $excludeHeaders ) )
954 {
955 $headers[] = array( 'name' => 'Content-Transfer-Encoding',
956 'content' => $this->ContentType['transfer-encoding'] );
957 $headerNames[] = 'content-transfer-encoding';
958 }
959 if ( !in_array( 'content-disposition', $excludeHeaders ) )
960 {
961 $headers[] = array( 'name' => 'Content-Disposition',
962 'content' => $this->ContentType['disposition'] );
963 $headerNames[] = 'content-disposition';
964 }
965 if ( !in_array( 'user-agent', $excludeHeaders ) )
966 {
967 $headers[] = array( 'name' => 'User-Agent',
968 'content' => $this->UserAgent );
969 $headerNames[] = 'user-agent';
970 }
971 if ( !in_array( 'message-id', $excludeHeaders ) )
972 {
973 if ( $this->MessageID )
974 {
975 $headers[] = array( 'name' => 'Message-Id',
976 'content' => $this->MessageID );
977 $headerNames[] = 'message-id';
978 }
979 }
980
981 $extraHeaders = $this->ExtraHeaders;
982 foreach ( $extraHeaders as $extraHeader )
983 {
984 if ( !in_array( strtolower( $extraHeader['name'] ), $excludeHeaders ) and
985 !in_array( strtolower( $extraHeader['name'] ), $headerNames ) )
986 $headers[] = $extraHeader;
987 }
988 return $headers;
989 }
990
997 function headerTextList( $parameters = array() )
998 {
999 $convert = true;
1000 if ( isset( $parameters['convert'] ) )
1001 $convert = $parameters['convert'];
1002 $textElements = array();
1003 $headers = $this->headers( $parameters );
1004 foreach ( $headers as $header )
1005 {
1006 $headerText = $this->blankNewlines( $header['name'] ) . ': ';
1007 $contentText = $this->blankNewlines( $this->contentString( $header['content'] ) );
1008 $headerText .= $contentText;
1009 $textElements[] = $headerText;
1010 }
1011 return $textElements;
1012 }
1013
1020 function headerText( $parameters = array() )
1021 {
1022 $convert = true;
1023 if ( isset( $parameters['convert'] ) )
1024 $convert = $parameters['convert'];
1025 $text = '';
1026 $headers = $this->headers( $parameters );
1027 $headerCount = 0;
1028 foreach ( $headers as $header )
1029 {
1030 if ( $headerCount++ > 0 )
1031 $text .= eZMail::lineSeparator();
1032 $text .= $this->blankNewlines( $header['name'] ) . ': ';
1033 $contentText = $this->blankNewlines( $this->contentString( $header['content'] ) );
1034 $text .= $contentText;
1035 }
1036 return $text;
1037 }
1038
1044 function convertHeaderText( $text )
1045 {
1046 $charset = $this->contentCharset();
1047 if ( $charset != 'us-ascii' )
1048 {
1049 $newText = $this->encodeMimeHeader( $text );
1050 return $newText;
1051 }
1052 return $text;
1053 }
1054
1060 function encodeMimeHeader( $str )
1061 {
1062 if ( !$this->TextCodec )
1063 {
1064 $this->TextCodec = eZTextCodec::instance( $this->contentCharset(), $this->outputCharset() );
1065 }
1066
1067 if ( function_exists( "mb_encode_mimeheader" ) )
1068 {
1069 $encoded = mb_encode_mimeheader( $str, $this->TextCodec->InputCharsetCode, "B", eZMail::lineSeparator() );
1070 }
1071 else
1072 {
1073 if ( 0 == preg_match_all( '/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches ) )
1074 return $str;
1075
1076 $maxlen = 75 - 7 - strlen( $this->TextCodec->InputCharsetCode );
1077
1078 $encoding = 'B';
1079 $encoded = base64_encode( $str );
1080 $maxlen -= $maxlen % 4;
1081 $encoded = trim( chunk_split( $encoded, $maxlen, "\n" ) );
1082
1083 $encoded = preg_replace( '/^(.*)$/m', " =?".$this->TextCodec->InputCharsetCode."?$encoding?\\1?=", $encoded );
1084
1085 $encoded = trim( str_replace( "\n", eZMail::lineSeparator(), $encoded ) );
1086 }
1087
1088 return $encoded;
1089 }
1090
1091
1098 function convertText( $text, $isHeader = false )
1099 {
1100
1101 $charset = $this->contentCharset();
1102 if ( $this->isAllowedCharset( $charset ) )
1103 return $text;
1104 $outputCharset = $this->outputCharset();
1105 if ( !$this->TextCodec )
1106 {
1107 $this->TextCodec = eZTextCodec::instance( $charset, $outputCharset );
1108 }
1109 $newText = $this->TextCodec->convertString( $text );
1110 return $newText;
1111 }
1112
1119 function isAllowedCharset( $charset )
1120 {
1121 $realCharset = eZCharsetInfo::realCharsetCode( $charset );
1122 $charsets = $this->allowedCharsets();
1123 foreach ( $charsets as $charsetName )
1124 {
1125 $realName = eZCharsetInfo::realCharsetCode( $charsetName );
1126 if ( $realName == $realCharset )
1127 return true;
1128 }
1129 return false;
1130 }
1131
1137 function allowedCharsets()
1138 {
1139 $ini = eZINI::instance();
1140 $charsets = $ini->variable( 'MailSettings', 'AllowedCharsets' );
1141 return $charsets;
1142 }
1143
1149 function usedCharset()
1150 {
1151 $charset = $this->contentCharset();
1152 if ( $this->isAllowedCharset( $charset ) )
1153 return $charset;
1154 return $this->outputCharset();
1155 }
1156
1162 function outputCharset()
1163 {
1164 $ini = eZINI::instance();
1165 $outputCharset = $ini->variable( 'MailSettings', 'OutputCharset' );
1166 return $outputCharset;
1167 }
1168
1174 static function lineSeparator()
1175 {
1176 $ini = eZINI::instance( 'site.ini' );
1177 $ending = $ini->variable( 'MailSettings', 'HeaderLineEnding' );
1178 if ( $ending == 'auto' )
1179 {
1180 $sys = eZSys::instance();
1181 // For windows we use \r\n which is the endline defined in RFC 2045
1182 if ( $sys->osType() == 'win32' )
1183 {
1184 $separator = "\r\n";
1185 }
1186 else // for linux/unix/mac we use \n only due to some mail transfer agents destroying
1187 // emails containing \r\n
1188 {
1189 $separator = "\n";
1190 }
1191 }
1192 else
1193 {
1194 $separator = urldecode( $ending );
1195 }
1196
1197 return $separator;
1198 }
1199
1200 /*
1201 // $subj = "=?$iso?B?" . trim( chunk_split( base64_encode( $subj ))) . "?=";
1202 */
1203
1205 public $ReceiverElements;
1206 public $From;
1207 public $CcElements;
1208 public $BccElements;
1209 public $ContentType;
1210 public $UserAgent;
1211 public $ReplyTo;
1212 public $Subject;
1213 public $BodyText;
1214 public $ExtraHeaders;
1215 public $TextCodec;
1216 public $MessageID;
1217 public $MIMEVersion;
1218
1227 public $Mail;
1228 }
1229
1230 ?>
eZCharsetInfo\realCharsetCode
static realCharsetCode( $charsetCode)
Definition: ezcharsetinfo.php:186
eZMail
Mail handler.
Definition: ezmail.php:60
eZMail\headers
headers( $parameters=array())
Definition: ezmail.php:870
eZMail\setExtraHeader
setExtraHeader( $headerName, $headerValue)
Definition: ezmail.php:590
eZMail\setContentType
setContentType( $type=false, $charset=false, $transferEncoding=false, $disposition=false, $boundary=false)
Definition: ezmail.php:374
eZMail\setMIMEVersion
setMIMEVersion( $version)
Definition: ezmail.php:362
eZMail\lineSeparator
static lineSeparator()
Definition: ezmail.php:1174
eZMail\extraHeaders
extraHeaders()
Definition: ezmail.php:568
eZMail\subject
subject( $convert=true)
Definition: ezmail.php:666
eZMail\convertText
convertText( $text, $isHeader=false)
Definition: ezmail.php:1098
eZMail\$Mail
$Mail
Definition: ezmail.php:1227
eZMail\setSender
setSender( $email, $name=false)
Definition: ezmail.php:487
eZMail\bccElements
bccElements()
Definition: ezmail.php:218
eZMail\senderText
senderText( $convert=true)
Definition: ezmail.php:278
eZMail\setSubject
setSubject( $newSubject)
Definition: ezmail.php:679
eZMail\setSenderText
setSenderText( $text)
Definition: ezmail.php:499
eZMail\addReceiver
addReceiver( $email, $name=false)
Definition: ezmail.php:463
eZMail\$BccElements
$BccElements
Definition: ezmail.php:1208
eZMail\REGEXP
const REGEXP
Definition: ezmail.php:62
eZMail\mimeVersion
mimeVersion()
Definition: ezmail.php:293
eZMail\blankNewlines
static blankNewlines( $text)
Definition: ezmail.php:795
eZMail\receiverText
receiverText( $convert=true)
Definition: ezmail.php:119
eZMail\outputCharset
outputCharset()
Definition: ezmail.php:1162
eZMail\headerText
headerText( $parameters=array())
Definition: ezmail.php:1020
eZMail\userAgent
userAgent( $convert=true)
Definition: ezmail.php:349
eZMail\$ContentType
$ContentType
Definition: ezmail.php:1209
eZMail\setMessageID
setMessageID( $newMessageID)
Definition: ezmail.php:635
eZMail\messageID
messageID()
Definition: ezmail.php:624
eZMail\receiverTextList
receiverTextList( $convert=true)
Definition: ezmail.php:164
eZMail\contentDisposition
contentDisposition()
Definition: ezmail.php:337
eZMail\usedCharset
usedCharset()
Definition: ezmail.php:1149
eZMail\setBccElements
setBccElements( $newBcc)
Definition: ezmail.php:540
eZMail\ccElements
ccElements()
Definition: ezmail.php:200
eZMail\setReceiver
setReceiver( $email, $name=false)
Definition: ezmail.php:436
eZMail\splitList
static & splitList( $emails)
Definition: ezmail.php:733
eZMail\$ReceiverElements
$ReceiverElements
Definition: ezmail.php:1205
eZMail\$ExtraHeaders
$ExtraHeaders
Definition: ezmail.php:1214
eZMail\extractEmail
static extractEmail( $text, &$email, &$name)
Definition: ezmail.php:757
eZMail\__construct
__construct()
Definition: ezmail.php:64
eZMail\replyTo
replyTo( $convert=true)
Definition: ezmail.php:237
eZMail\$Subject
$Subject
Definition: ezmail.php:1212
eZMail\receiverEmailText
receiverEmailText( $convert=true)
Definition: ezmail.php:101
eZMail\$From
$From
Definition: ezmail.php:1206
eZMail\setCcElements
setCcElements( $newCc)
Definition: ezmail.php:512
eZMail\$UserAgent
$UserAgent
Definition: ezmail.php:1210
eZMail\headerTextList
headerTextList( $parameters=array())
Definition: ezmail.php:997
eZMail\$CcElements
$CcElements
Definition: ezmail.php:1207
eZMail\$MessageID
$MessageID
Definition: ezmail.php:1216
eZMail\composeEmailName
composeEmailName( $item, $key=false, $convert=true)
Definition: ezmail.php:822
eZMail\contentType
contentType()
Definition: ezmail.php:304
eZMail\bccReceiverTextList
bccReceiverTextList( $convert=true)
Definition: ezmail.php:146
eZMail\contentCharset
contentCharset()
Definition: ezmail.php:316
eZMail\sender
sender( $convert=true)
Definition: ezmail.php:250
eZMail\addCc
addCc( $email, $name=false)
Definition: ezmail.php:528
eZMail\composeEmailItems
composeEmailItems( $items, $join=true, $key=false, $convert=true)
Definition: ezmail.php:844
eZMail\$BodyText
$BodyText
Definition: ezmail.php:1213
eZMail\setBody
setBody( $newBody)
Definition: ezmail.php:704
eZMail\setExtraHeaders
setExtraHeaders( $headers)
Definition: ezmail.php:612
eZMail\body
body( $convert=true)
Definition: ezmail.php:691
eZMail\encodeMimeHeader
encodeMimeHeader( $str)
Definition: ezmail.php:1060
eZMail\setReferences
setReferences( $newReference)
Definition: ezmail.php:656
eZMail\convertHeaderText
convertHeaderText( $text)
Definition: ezmail.php:1044
eZMail\contentTransferEncoding
contentTransferEncoding()
Definition: ezmail.php:326
eZMail\allowedCharsets
allowedCharsets()
Definition: ezmail.php:1137
eZMail\$References
$References
Definition: ezmail.php:61
eZMail\stripEmail
static stripEmail( $address)
Definition: ezmail.php:779
eZMail\validate
static validate( $address)
Definition: ezmail.php:747
eZMail\$ReplyTo
$ReplyTo
Definition: ezmail.php:1211
eZMail\ccReceiverTextList
ccReceiverTextList( $convert=true)
Definition: ezmail.php:130
eZMail\isAllowedCharset
isAllowedCharset( $charset)
Definition: ezmail.php:1119
eZMail\setReplyTo
setReplyTo( $email, $name=false)
Definition: ezmail.php:475
eZMail\references
references()
Definition: ezmail.php:646
eZMail\setReceiverText
setReceiverText( $text)
Definition: ezmail.php:450
eZMail\$TextCodec
$TextCodec
Definition: ezmail.php:1215
eZMail\setUserAgent
setUserAgent( $agent)
Definition: ezmail.php:407
eZMail\contentString
static contentString( $content)
Definition: ezmail.php:807
eZMail\addExtraHeader
addExtraHeader( $headerName, $headerValue)
Definition: ezmail.php:578
eZMail\$MIMEVersion
$MIMEVersion
Definition: ezmail.php:1217
eZMail\setReceiverElements
setReceiverElements( $toElements)
Definition: ezmail.php:418
eZMail\receiverElements
receiverElements()
Definition: ezmail.php:182
eZMail\addBcc
addBcc( $email, $name=false)
Definition: ezmail.php:556
eZSys\instance
static instance()
Definition: ezsys.php:1272
eZTextCodec\instance
static instance( $inputCharsetCode, $outputCharsetCode=false, $alwaysReturn=true)
Definition: eztextcodec.php:446
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.