60 var
$priorities = array(
'1 (Highest)',
'2 (High)',
'3 (Normal)',
'4 (Low)',
'5 (Lowest)' );
77 $this->boundary=
"--" . md5( uniqid(
"myboundary") );
91 $this->checkAddress =
true;
93 $this->checkAddress =
false;
101 function Subject($subject, $a_add_prefix =
false)
106 include_once
"Services/Mail/classes/class.ilMail.php";
110 $subject = trim($prefix).
" ".$subject;
125 if( ! is_string($from) ) {
126 echo
"Class Mail: error, From is not a string";
132 $this->xheaders[
'From'] = $from;
142 if( ! is_string($address) )
145 $this->xheaders[
"Reply-To"] = $address;
171 if( is_array( $to ) )
174 $this->sendto[] = $to;
176 if( $this->checkAddress ==
true )
195 if( $this->checkAddress ==
true )
211 if( is_array($bcc) ) {
217 if( $this->checkAddress ==
true )
236 $this->charset = strtolower(
$charset);
237 if( $this->charset ==
"us-ascii" )
238 $this->ctencoding =
"7bit";
250 if( trim( $org !=
"" ) )
251 $this->xheaders[
'Organization'] = $org;
264 if( ! intval( $priority ) )
267 if( ! isset( $this->priorities[$priority-1]) )
270 $this->xheaders[
"X-Priority"] = $this->priorities[$priority-1];
285 function Attach(
$filename, $filetype =
"", $disposition =
"inline", $display_name = null)
288 if( $filetype ==
"" )
289 $filetype =
"application/octet-stream";
292 $this->actype[] = $filetype;
293 $this->adispo[] = $disposition;
294 $this->adisplay[] = $display_name;
308 if( count($this->acc) > 0 )
309 $this->xheaders[
'CC'] = implode(
", ", $this->acc );
311 if( count($this->abcc) > 0 )
312 $this->xheaders[
'BCC'] = implode(
", ", $this->abcc );
315 if( $this->receipt ) {
316 if( isset($this->xheaders[
"Reply-To"] ) )
317 $this->xheaders[
"Disposition-Notification-To"] = $this->xheaders[
"Reply-To"];
319 $this->xheaders[
"Disposition-Notification-To"] = $this->xheaders[
'From'];
322 if( $this->charset !=
"" ) {
323 $this->xheaders[
"Mime-Version"] =
"1.0";
324 $this->xheaders[
"Content-Type"] =
"text/plain; charset=$this->charset";
328 $this->xheaders[
"X-Mailer"] =
"Php/libMailv1.3";
331 if( count( $this->aattach ) > 0 ) {
334 $this->fullBody = $this->body;
337 reset($this->xheaders);
338 while( list( $hdr,$value ) = each( $this->xheaders ) ) {
339 if( $hdr !=
"Subject" )
340 $this->headers .=
"$hdr: $value\n";
357 $this->strTo = implode(
", ", $this->sendto );
360 if(!(
int)$ilSetting->get(
'prevent_smtp_globally'))
362 $res = @mail( $this->strTo, $this->xheaders[
'Subject'], $this->fullBody, $this->headers );
364 #$ilLog->write($this->strTo.' '. $this->xheaders['Subject'].' '. $this->fullBody.' '. $this->headers);
377 $mail =
"To: " . $this->strTo .
"\n";
378 $mail .= $this->headers .
"\n";
379 $mail .= $this->fullBody;
393 if( ereg(
".*<(.+)>", $address, $regs ) ) {
396 if(ereg(
"^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$",$address) )
411 for($i=0;$i< count( $aad); $i++ ) {
413 echo
"Class Mail, method Mail : invalid address $aad[$i]";
428 $this->xheaders[
"Content-Type"] =
"multipart/mixed;\n boundary=\"$this->boundary\"";
430 $this->fullBody =
"This is a multi-part message in MIME format.\n--$this->boundary\n";
431 $this->fullBody .=
"Content-Type: text/plain; charset=$this->charset\nContent-Transfer-Encoding: $this->ctencoding\n\n".
434 $sep= chr(13) . chr(10);
440 for( $i=0; $i < count( $this->aattach); $i++ ) {
444 $ctype = $this->actype[$i];
445 $disposition = $this->adispo[$i];
446 $display_name = $this->adisplay[$i];
449 $display_name = $basename;
453 echo
"Class Mail, method attach : file $filename can't be found";
exit;
455 $subhdr=
"--$this->boundary\nContent-type: $ctype;\n name=\"$basename\"\nContent-Transfer-Encoding:".
456 "base64\nContent-Disposition: $disposition;\n filename=\"$display_name\"\n\n";
457 $ata[$k++] = $subhdr;
461 $ata[$k++] = chunk_split(base64_encode(fread( $fp, $linesz)));
464 $this->fullBody .= implode($sep, $ata);
469 $encoded =
'=?utf-8?b?';
470 $encoded .= base64_encode($a_string);