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;
154 if( ! is_string($address) )
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";
367 $this->strTo = implode(
", ", $this->sendto );
370 if(!(
int)$ilSetting->get(
'prevent_smtp_globally'))
372 $res = @mail( $this->strTo, $this->xheaders[
'Subject'], $this->fullBody, $this->headers );
374 #$ilLog->write($this->strTo.' '. $this->xheaders['Subject'].' '. $this->fullBody.' '. $this->headers);
387 $mail =
"To: " . $this->strTo .
"\n";
388 $mail .= $this->headers .
"\n";
389 $mail .= $this->fullBody;
403 if( ereg(
".*<(.+)>", $address, $regs ) ) {
406 if(ereg(
"^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$",$address) )
421 for($i=0;$i< count( $aad); $i++ ) {
423 echo
"Class Mail, method Mail : invalid address $aad[$i]";
438 $this->xheaders[
"Content-Type"] =
"multipart/mixed;\n boundary=\"$this->boundary\"";
440 $this->fullBody =
"This is a multi-part message in MIME format.\n--$this->boundary\n";
441 $this->fullBody .=
"Content-Type: text/plain; charset=$this->charset\nContent-Transfer-Encoding: $this->ctencoding\n\n".
444 $sep= chr(13) . chr(10);
450 for( $i=0; $i < count( $this->aattach); $i++ ) {
454 $ctype = $this->actype[$i];
455 $disposition = $this->adispo[$i];
458 echo
"Class Mail, method attach : file $filename can't be found";
exit;
460 $subhdr=
"--$this->boundary\nContent-type: $ctype;\n name=\"$basename\"\nContent-Transfer-Encoding:".
461 "base64\nContent-Disposition: $disposition;\n filename=\"$basename\"\n\n";
462 $ata[$k++] = $subhdr;
466 $ata[$k++] = chunk_split(base64_encode(fread( $fp, $linesz)));
469 $this->fullBody .= implode($sep, $ata);
474 $encoded =
'=?utf-8?b?';
475 $encoded .= base64_encode($a_string);