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;
115 if( ! is_string($from) ) {
116 echo
"Class Mail: error, From is not a string";
122 $this->xheaders[
'From'] = $from;
132 if( ! is_string($address) )
135 $this->xheaders[
"Reply-To"] = $address;
161 if( is_array( $to ) )
164 $this->sendto[] = $to;
166 if( $this->checkAddress ==
true )
185 if( $this->checkAddress ==
true )
201 if( is_array($bcc) ) {
207 if( $this->checkAddress ==
true )
226 $this->charset = strtolower(
$charset);
227 if( $this->charset ==
"us-ascii" )
228 $this->ctencoding =
"7bit";
240 if( trim( $org !=
"" ) )
241 $this->xheaders[
'Organization'] = $org;
254 if( ! intval( $priority ) )
257 if( ! isset( $this->priorities[$priority-1]) )
260 $this->xheaders[
"X-Priority"] = $this->priorities[$priority-1];
275 function Attach(
$filename, $filetype =
"", $disposition =
"inline", $display_name = null)
278 if( $filetype ==
"" )
279 $filetype =
"application/octet-stream";
282 $this->actype[] = $filetype;
283 $this->adispo[] = $disposition;
284 $this->adisplay[] = $display_name;
298 if( count($this->acc) > 0 )
299 $this->xheaders[
'CC'] = implode(
", ", $this->acc );
301 if( count($this->abcc) > 0 )
302 $this->xheaders[
'BCC'] = implode(
", ", $this->abcc );
305 if( $this->receipt ) {
306 if( isset($this->xheaders[
"Reply-To"] ) )
307 $this->xheaders[
"Disposition-Notification-To"] = $this->xheaders[
"Reply-To"];
309 $this->xheaders[
"Disposition-Notification-To"] = $this->xheaders[
'From'];
312 if( $this->charset !=
"" ) {
313 $this->xheaders[
"Mime-Version"] =
"1.0";
314 $this->xheaders[
"Content-Type"] =
"text/plain; charset=$this->charset";
318 $this->xheaders[
"X-Mailer"] =
"Php/libMailv1.3";
321 if( count( $this->aattach ) > 0 ) {
324 $this->fullBody = $this->body;
327 reset($this->xheaders);
328 while( list( $hdr,$value ) = each( $this->xheaders ) ) {
329 if( $hdr !=
"Subject" )
330 $this->headers .=
"$hdr: $value\n";
347 $this->strTo = implode(
", ", $this->sendto );
350 if(!(
int)$ilSetting->get(
'prevent_smtp_globally'))
352 $res = @mail( $this->strTo, $this->xheaders[
'Subject'], $this->fullBody, $this->headers );
354 #$ilLog->write($this->strTo.' '. $this->xheaders['Subject'].' '. $this->fullBody.' '. $this->headers);
367 $mail =
"To: " . $this->strTo .
"\n";
368 $mail .= $this->headers .
"\n";
369 $mail .= $this->fullBody;
383 if( ereg(
".*<(.+)>", $address, $regs ) ) {
386 if(ereg(
"^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$",$address) )
401 for($i=0;$i< count( $aad); $i++ ) {
403 echo
"Class Mail, method Mail : invalid address $aad[$i]";
418 $this->xheaders[
"Content-Type"] =
"multipart/mixed;\n boundary=\"$this->boundary\"";
420 $this->fullBody =
"This is a multi-part message in MIME format.\n--$this->boundary\n";
421 $this->fullBody .=
"Content-Type: text/plain; charset=$this->charset\nContent-Transfer-Encoding: $this->ctencoding\n\n".
424 $sep= chr(13) . chr(10);
430 for( $i=0; $i < count( $this->aattach); $i++ ) {
434 $ctype = $this->actype[$i];
435 $disposition = $this->adispo[$i];
436 $display_name = $this->adisplay[$i];
439 $display_name = $basename;
443 echo
"Class Mail, method attach : file $filename can't be found";
exit;
445 $subhdr=
"--$this->boundary\nContent-type: $ctype;\n name=\"$basename\"\nContent-Transfer-Encoding:".
446 "base64\nContent-Disposition: $disposition;\n filename=\"$display_name\"\n\n";
447 $ata[$k++] = $subhdr;
451 $ata[$k++] = chunk_split(base64_encode(fread( $fp, $linesz)));
454 $this->fullBody .= implode($sep, $ata);
459 $encoded =
'=?utf-8?b?';
460 $encoded .= base64_encode($a_string);