4 require_once
'./Services/Logging/classes/public/class.ilLoggerFactory.php';
67 var
$priorities = array(
'1 (Highest)',
'2 (High)',
'3 (Normal)',
'4 (Low)',
'5 (Lowest)' );
83 $this->boundary=
"--" . md5( uniqid(
"myboundary") );
97 $this->checkAddress =
true;
101 $this->checkAddress =
false;
109 function Subject($subject, $a_add_prefix =
false)
114 include_once
"Services/Mail/classes/class.ilMail.php";
118 $subject = trim($prefix).
" ".$subject;
121 $this->xheaders[
'Subject'] = $subject;
130 if( ! is_string($from) && !is_array($from)) {
131 echo
"Class Mail: error, From is not a string or array";
136 $this->xheaders[
'From'] = $from[0];
137 $this->xheaders[
'FromName'] = $from[1];
141 $this->xheaders[
'From'] = $from;
150 if( ! is_string($address) )
155 $this->xheaders[
"Reply-To"] = $address;
175 if( is_array( $to ) )
181 $this->sendto[] = $to;
184 if( $this->checkAddress ==
true )
207 if( $this->checkAddress ==
true )
230 if( $this->checkAddress ==
true )
245 function Body( $body, $charset=
"" )
251 $this->charset = strtolower($charset);
252 if( $this->charset ==
"us-ascii" )
254 $this->ctencoding =
"7bit";
266 if( trim( $org !=
"" ) )
268 $this->xheaders[
'Organization'] = $org;
281 if( ! intval( $priority ) )
286 if( ! isset( $this->priorities[$priority-1]) )
291 $this->xheaders[
"X-Priority"] = $this->priorities[$priority-1];
303 function Attach(
$filename, $filetype =
"", $disposition =
"inline", $display_name = null)
306 if( $filetype ==
"" )
308 $filetype =
"application/octet-stream";
312 $this->actype[] = $filetype;
313 $this->adispo[] = $disposition;
314 $this->adisplay[] = $display_name;
330 require_once
'./Services/Mail/phpmailer/class.phpmailer.php';
333 if($ilSetting->get(
'mail_system_return_path',
''))
335 $mail->Sender = $ilSetting->get(
'mail_system_return_path',
'');
338 require_once
'Services/Mail/classes/class.ilMail.php';
340 if($this->xheaders[
'From'] == $addr[0])
342 $mail->setFrom($this->xheaders[
'From'], $this->xheaders[
'FromName']);
346 $mail->addReplyTo($this->xheaders[
'From'], $this->xheaders[
'FromName']);
347 $mail->setFrom($addr[0], $addr[1]);
349 foreach($this->sendto as $recipients)
351 $recipient_pieces = array_filter(array_map(
'trim', explode(
',', $recipients)));
352 foreach($recipient_pieces as $recipient)
354 $mail->AddAddress($recipient,
'');
358 foreach($this->acc as $carbon_copies)
360 $cc_pieces = array_filter(array_map(
'trim', explode(
',', $carbon_copies)));
361 foreach($cc_pieces as $carbon_copy)
363 $mail->AddCC($carbon_copy,
'');
367 foreach($this->abcc as $blind_carbon_copies)
369 $bcc_pieces = array_filter(array_map(
'trim', explode(
',', $blind_carbon_copies)));
370 foreach($bcc_pieces as $blind_carbon_copy)
372 $mail->AddBCC($blind_carbon_copy,
'');
376 $mail->CharSet =
'utf-8';
377 $mail->Subject = $this->xheaders[
'Subject'];
379 if($ilSetting->get(
'mail_send_html', 0))
383 $skin = $ilClientIniFile->readVariable(
'layout',
'skin');
385 $bracket_path =
'./Services/Mail/templates/default/tpl.html_mail_template.html';
386 if($skin !=
'default')
388 $tplpath =
'./Customizing/global/skin/' . $skin .
'/Services/Mail/tpl.html_mail_template.html';
390 if(@file_exists($tplpath))
392 $bracket_path =
'./Customizing/global/skin/' . $skin .
'/Services/Mail/tpl.html_mail_template.html';
395 $bracket = file_get_contents($bracket_path);
402 $mail->AltBody = $this->body;
404 if(strip_tags($this->body,
'<b><u><i><a>') == $this->body)
407 $this->body = nl2br($this->body);
411 $directory =
'./Services/Mail/templates/default/img/';
412 if($skin !=
'default')
414 if(is_dir(
'./Customizing/global/skin/' . $skin .
'/Services/Mail/img'))
416 $directory =
'./Customizing/global/skin/' . $skin .
'/Services/Mail/img/';
419 $directory_handle = @opendir($directory);
421 if($directory_handle)
423 while (
$filename = @readdir($directory_handle))
428 $images = preg_grep (
'/\.jpg$/i', $files);
430 foreach($images as $image)
432 $mail->AddEmbeddedImage($directory.$image,
'img/'.$image, $image);
438 $mail->IsHTML(
false);
439 $mail->Body = $this->body;
443 foreach($this->aattach as $attachment)
446 if(isset($this->adisplay[$i]) && strlen($this->adisplay[$i]) > 0)
448 $name = $this->adisplay[$i];
451 $mail->AddAttachment($attachment, $name);
456 "Trying to delegate external email delivery:" .
457 " Initiated by: " . $ilUser->getLogin() .
" (" . $ilUser->getId() .
")" .
458 " | From: " . $this->xheaders[
'From'] .
459 " | To: " . implode(
', ', $this->sendto) .
460 " | CC: " . implode(
', ', $this->acc) .
461 " | BCC: " . implode(
', ', $this->abcc) .
462 " | Subject: " .$mail->Subject
465 if(!(
int)$ilSetting->get(
'prevent_smtp_globally'))
472 'Successfully delegated external mail delivery' 478 'Could not deliver external email: %s', $mail->ErrorInfo
485 'Suppressed delegation of email delivery according to global setting ( prevent_smtp_globally ).' 506 $mail =
"To: " . $this->strTo .
"\n";
507 $mail .= $this->headers .
"\n";
508 $mail .= $this->fullBody;
521 if( ereg(
".*<(.+)>", $address, $regs ) ) {
524 if(ereg(
"^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$",$address) )
541 for($i=0;$i< count( $aad); $i++ ) {
544 echo
"Class Mail, method Mail : invalid address $aad[$i]";
556 $this->xheaders[
"Content-Type"] =
"multipart/mixed;\n boundary=\"$this->boundary\"";
558 $this->fullBody =
"This is a multi-part message in MIME format.\n--$this->boundary\n";
559 $this->fullBody .=
"Content-Type: text/plain; charset=$this->charset\nContent-Transfer-Encoding: $this->ctencoding\n\n".
562 $sep= chr(13) . chr(10);
568 for( $i=0; $i < count( $this->aattach); $i++ ) {
572 $ctype = $this->actype[$i];
573 $disposition = $this->adispo[$i];
574 $display_name = $this->adisplay[$i];
577 $display_name = $basename;
581 echo
"Class Mail, method attach : file $filename can't be found";
585 $subhdr=
"--$this->boundary\nContent-type: $ctype;\n name=\"$basename\"\nContent-Transfer-Encoding:".
586 "base64\nContent-Disposition: $disposition;\n filename=\"$display_name\"\n\n";
587 $ata[$k++] = $subhdr;
591 $ata[$k++] = chunk_split(base64_encode(fread( $fp, $linesz)));
595 $this->fullBody .= implode($sep, $ata);
600 $encoded =
'=?utf-8?b?';
601 $encoded .= base64_encode($a_string);
Attach( $filename, $filetype="", $disposition="inline", $display_name=null)
Attach a file to the mail.
ReplyTo( $address)
set the Reply-to header
_build_attachement()
check and encode attach file(s) .
Get()
return the whole e-mail , headers + message can be used for displaying the message in plain text or l...
Cc($cc)
Cc() cc : email address(es), accept both array and string.
__construct()
Mail contructor.
autoCheck($bool)
activate or desactivate the email addresses validator ex: autoCheck( true ) turn the validator on by ...
To( $to)
set the mail recipient
PHPMailer - PHP email creation and transport class.
Priority( $priority)
Priority( $priority ) set the mail priority $priority : integer taken between 1 (highest) and 5 ( low...
this class encapsulates the PHP mail() function.
ValidEmail($address)
check an email address validity public
From($from)
set the sender of the mail
static makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen
Body( $body, $charset="")
Body( text [, charset] ) set the body (message) of the mail define the charset if the message contain...
Subject($subject, $a_add_prefix=false)
Define the subject line of the email.
Organization( $org)
Organization( $org ) set the Organization header.
Bcc( $bcc)
Bcc() set the Bcc headers ( blank carbon copy ).
Send()
fornat and send the mail public
CheckAdresses( $aad)
check validity of email addresses return if unvalid, output an error message and exit, this may -should- be customized
Receipt()
add a receipt to the mail ie.
static getLogger($a_component_id)
Get component logger.
static getSubjectPrefix()
Get text that will be prepended to auto generated mails.
static getIliasMailerAddress()
Builds an email address used for system notifications.