81 var
$priorities = array(
'1 (Highest)',
'2 (High)',
'3 (Normal)',
'4 (Low)',
'5 (Lowest)' );
99 $this->boundary=
"--" . md5( uniqid(
"myboundary") );
113 $this->checkAddress =
true;
115 $this->checkAddress =
false;
137 if( ! is_string($from) ) {
138 echo
"Class Mail: error, From is not a string";
144 $this->xheaders[
'From'] = $from;
157 $this->xheaders[
"Reply-To"] =
$address;
183 if( is_array( $to ) )
186 $this->sendto[] = $to;
188 if( $this->checkAddress ==
true )
207 if( $this->checkAddress ==
true )
223 if( is_array($bcc) ) {
229 if( $this->checkAddress ==
true )
248 $this->charset = strtolower(
$charset);
249 if( $this->charset ==
"us-ascii" )
250 $this->ctencoding =
"7bit";
262 if( trim( $org !=
"" ) )
263 $this->xheaders[
'Organization'] = $org;
276 if( ! intval( $priority ) )
279 if( ! isset( $this->priorities[$priority-1]) )
282 $this->xheaders[
"X-Priority"] = $this->priorities[$priority-1];
299 if( $filetype ==
"" )
300 $filetype =
"application/octet-stream";
303 $this->actype[] = $filetype;
304 $this->adispo[] = $disposition;
318 if( count($this->acc) > 0 )
319 $this->xheaders[
'CC'] = implode(
", ", $this->acc );
321 if( count($this->abcc) > 0 )
322 $this->xheaders[
'BCC'] = implode(
", ", $this->abcc );
325 if( $this->receipt ) {
326 if( isset($this->xheaders[
"Reply-To"] ) )
327 $this->xheaders[
"Disposition-Notification-To"] = $this->xheaders[
"Reply-To"];
329 $this->xheaders[
"Disposition-Notification-To"] = $this->xheaders[
'From'];
332 if( $this->charset !=
"" ) {
333 $this->xheaders[
"Mime-Version"] =
"1.0";
334 $this->xheaders[
"Content-Type"] =
"text/plain; charset=$this->charset";
338 $this->xheaders[
"X-Mailer"] =
"Php/libMailv1.3";
341 if( count( $this->aattach ) > 0 ) {
344 $this->fullBody = $this->body;
347 reset($this->xheaders);
348 while( list( $hdr,$value ) = each( $this->xheaders ) ) {
349 if( $hdr !=
"Subject" )
350 $this->headers .=
"$hdr: $value\n";
366 $this->strTo = implode(
", ", $this->sendto );
369 $res = @mail( $this->strTo, $this->xheaders[
'Subject'], $this->fullBody, $this->headers );
370 #$ilLog->write($this->strTo.' '. $this->xheaders['Subject'].' '. $this->fullBody.' '. $this->headers);
383 $mail =
"To: " . $this->strTo .
"\n";
384 $mail .= $this->headers .
"\n";
385 $mail .= $this->fullBody;
399 if( ereg(
".*<(.+)>",
$address, $regs ) ) {
402 if(ereg(
"^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$",
$address) )
417 for($i=0;$i< count( $aad); $i++ ) {
419 echo
"Class Mail, method Mail : invalid address $aad[$i]";
434 $this->xheaders[
"Content-Type"] =
"multipart/mixed;\n boundary=\"$this->boundary\"";
436 $this->fullBody =
"This is a multi-part message in MIME format.\n--$this->boundary\n";
437 $this->fullBody .=
"Content-Type: text/plain; charset=$this->charset\nContent-Transfer-Encoding: $this->ctencoding\n\n".
440 $sep= chr(13) . chr(10);
446 for( $i=0; $i < count( $this->aattach); $i++ ) {
450 $ctype = $this->actype[$i];
451 $disposition = $this->adispo[$i];
454 echo
"Class Mail, method attach : file $filename can't be found";
exit;
456 $subhdr=
"--$this->boundary\nContent-type: $ctype;\n name=\"$basename\"\nContent-Transfer-Encoding:".
457 "base64\nContent-Disposition: $disposition;\n filename=\"$basename\"\n\n";
458 $ata[$k++] = $subhdr;
462 $ata[$k++] = chunk_split(base64_encode(fread( $fp, $linesz)));
465 $this->fullBody .= implode($sep, $ata);
470 $encoded =
'=?utf-8?b?';
471 $encoded .= base64_encode($a_string);