4require_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") );
 
   98                        $this->checkAddress = 
true;
 
  102                        $this->checkAddress = 
false;
 
  110        function Subject($subject, $a_add_prefix = 
false)
 
  115                        include_once 
"Services/Mail/classes/class.ilMail.php";
 
  116                        $prefix = ilMail::getSubjectPrefix();
 
  119                                $subject = trim($prefix).
" ".$subject;
 
  122                $this->xheaders[
'Subject'] = $subject;
 
  131                if( ! is_string($from) && !is_array($from)) {
 
  132                        echo 
"Class Mail: error, From is not a string or array";
 
  137                        $this->xheaders[
'From']     = $from[0];
 
  138                        $this->xheaders[
'FromName'] = $from[1];
 
  142                $this->xheaders[
'From'] = $from;
 
  151                if( ! is_string($address) )
 
  156                $this->xheaders[
"Reply-To"] = $address;
 
  176                if( is_array( $to ) )
 
  182                        $this->sendto[] = $to;
 
  185                if( $this->checkAddress == 
true )
 
  208                if( $this->checkAddress == 
true )
 
  231                if( $this->checkAddress == 
true )
 
  252                        $this->charset = strtolower(
$charset);
 
  253                        if( $this->charset == 
"us-ascii" )
 
  255                                $this->ctencoding = 
"7bit";
 
  267                if( trim( $org != 
"" )  )
 
  269                        $this->xheaders[
'Organization'] = $org;
 
  282                if( ! intval( $priority ) )
 
  287                if( ! isset( $this->priorities[$priority-1]) )
 
  292                $this->xheaders[
"X-Priority"] = $this->priorities[$priority-1];
 
  304        function Attach( 
$filename, $filetype = 
"", $disposition = 
"inline", $display_name = 
null)
 
  307                if( $filetype == 
"" )
 
  309                        $filetype = 
"application/octet-stream";
 
  313                $this->actype[] = $filetype;
 
  314                $this->adispo[] = $disposition;
 
  315                $this->adisplay[] = $display_name;
 
  322        protected function BuildMail()
 
  331                require_once 
'libs/composer/vendor/autoload.php';
 
  334                if(
$ilSetting->get(
'mail_system_return_path', 
''))
 
  336                        $mail->Sender = 
$ilSetting->get(
'mail_system_return_path', 
'');
 
  339                require_once 
'Services/Mail/classes/class.ilMail.php';
 
  340                $addr = ilMail::getIliasMailerAddress();
 
  341                if($this->xheaders[
'From'] == $addr[0])
 
  343                        $mail->setFrom($this->xheaders[
'From'], $this->xheaders[
'FromName']);
 
  347                        $mail->addReplyTo($this->xheaders[
'From'], $this->xheaders[
'FromName']);
 
  348                        $mail->setFrom($addr[0], $addr[1]);
 
  350                foreach($this->sendto as $recipients)
 
  352                        $recipient_pieces = array_filter(array_map(
'trim', explode(
',', $recipients)));
 
  353                        foreach($recipient_pieces as $recipient)
 
  355                                $mail->AddAddress($recipient, 
'');
 
  359                foreach($this->acc as $carbon_copies)
 
  361                        $cc_pieces = array_filter(array_map(
'trim', explode(
',', $carbon_copies)));
 
  362                        foreach($cc_pieces as $carbon_copy)
 
  364                                $mail->AddCC($carbon_copy, 
'');
 
  368                foreach($this->abcc as $blind_carbon_copies)
 
  370                        $bcc_pieces = array_filter(array_map(
'trim', explode(
',', $blind_carbon_copies)));
 
  371                        foreach($bcc_pieces as $blind_carbon_copy)
 
  373                                $mail->AddBCC($blind_carbon_copy, 
'');
 
  377                $mail->CharSet = 
'utf-8';
 
  378                $mail->Subject = $this->xheaders[
'Subject'];
 
  384                        $skin = $ilClientIniFile->readVariable(
'layout', 
'skin');
 
  386                        $bracket_path = 
'./Services/Mail/templates/default/tpl.html_mail_template.html';
 
  387                        if($skin != 
'default')
 
  389                                $tplpath = 
'./Customizing/global/skin/' . $skin . 
'/Services/Mail/tpl.html_mail_template.html';
 
  391                                if(@file_exists($tplpath))
 
  393                                        $bracket_path = 
'./Customizing/global/skin/' . $skin . 
'/Services/Mail/tpl.html_mail_template.html';
 
  396                        $bracket = file_get_contents($bracket_path);
 
  403                        $mail->AltBody = $this->body;
 
  405                        if(strip_tags($this->body, 
'<b><u><i><a>') == $this->body)
 
  408                                $this->body = nl2br($this->body);
 
  412                        $directory = 
'./Services/Mail/templates/default/img/';
 
  413                        if($skin != 
'default')
 
  415                                if(is_dir(
'./Customizing/global/skin/' . $skin . 
'/Services/Mail/img'))
 
  417                                        $directory = 
'./Customizing/global/skin/' . $skin . 
'/Services/Mail/img/';
 
  420                        $directory_handle  = @opendir($directory);
 
  422                        if($directory_handle)
 
  424                                while (
$filename = @readdir($directory_handle))
 
  429                                $images = preg_grep (
'/\.jpg$/i', 
$files);
 
  431                                foreach($images as $image)
 
  433                                        $mail->AddEmbeddedImage($directory.$image, 
'img/'.$image, $image);
 
  439                        $mail->IsHTML(
false);
 
  440                        $mail->Body = $this->body;
 
  444                foreach($this->aattach as $attachment)
 
  447                        if(isset($this->adisplay[$i]) && strlen($this->adisplay[$i]) > 0)
 
  449                                $name = $this->adisplay[$i];
 
  452                        $mail->AddAttachment($attachment, $name);
 
  457                        "Trying to delegate external email delivery:" .
 
  458                        " Initiated by: " . 
$ilUser->getLogin() . 
" (" . 
$ilUser->getId() . 
")" .
 
  459                        " | From: " . $this->xheaders[
'From'] .
 
  460                        " | To: " . implode(
', ', $this->sendto) .
 
  461                        " | CC: " . implode(
', ', $this->acc) .
 
  462                        " | BCC: " . implode(
', ', $this->abcc) .
 
  463                        " | Subject: " .$mail->Subject
 
  466                if(!(
int)
$ilSetting->get(
'prevent_smtp_globally'))
 
  473                                        'Successfully delegated external mail delivery' 
  479                                        'Could not deliver external email: %s', $mail->ErrorInfo
 
  486                                'Suppressed delegation of email delivery according to global setting ( prevent_smtp_globally ).' 
  507                $mail = 
"To: " . $this->strTo . 
"\n";
 
  508                $mail .= $this->headers . 
"\n";
 
  509                $mail .= $this->fullBody;
 
  524                if(preg_match(
"/.*<(.+)>/", $address, $regs))
 
  529                if(preg_match(
'/^[^@  ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)$/', $address))
 
  547                for($i=0;$i< count( $aad); $i++ ) {
 
  550                                echo 
"Class Mail, method Mail : invalid address $aad[$i]";
 
  562                $this->xheaders[
"Content-Type"] = 
"multipart/mixed;\n boundary=\"$this->boundary\"";
 
  564                $this->fullBody = 
"This is a multi-part message in MIME format.\n--$this->boundary\n";
 
  565                $this->fullBody .= 
"Content-Type: text/plain; charset=$this->charset\nContent-Transfer-Encoding: $this->ctencoding\n\n".
 
  568                $sep= chr(13) . chr(10);
 
  574                for( $i=0; $i < count( $this->aattach); $i++ ) {
 
  578                        $ctype = $this->actype[$i];     
 
  579                        $disposition = $this->adispo[$i];
 
  580                        $display_name = $this->adisplay[$i];
 
  583                                $display_name = $basename;
 
  587                                echo 
"Class Mail, method attach : file $filename can't be found"; 
 
  591                        $subhdr= 
"--$this->boundary\nContent-type: $ctype;\n name=\"$basename\"\nContent-Transfer-Encoding:".
 
  592                                "base64\nContent-Disposition: $disposition;\n  filename=\"$display_name\"\n\n";
 
  593                        $ata[$k++] = $subhdr;
 
  597                        $ata[$k++] = chunk_split(base64_encode(fread( $fp, $linesz)));
 
  601                $this->fullBody .= implode($sep, $ata);
 
  606                $encoded = 
'=?utf-8?b?';
 
  607                $encoded .= base64_encode($a_string);
 
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
static getLogger($a_component_id)
Get component logger.
this class encapsulates the PHP mail() function.
CheckAdresses( $aad)
check validity of email addresses return if unvalid, output an error message and exit,...
Cc($cc)
Cc() cc : email address(es), accept both array and string.
From($from)
set the sender of the mail
_build_attachement()
check and encode attach file(s) .
Bcc( $bcc)
Bcc() set the Bcc headers ( blank carbon copy ).
Get()
return the whole e-mail , headers + message can be used for displaying the message in plain text or l...
static _mimeEncode($a_string)
autoCheck($bool)
activate or desactivate the email addresses validator ex: autoCheck( true ) turn the validator on by ...
Attach( $filename, $filetype="", $disposition="inline", $display_name=null)
Attach a file to the mail.
Send()
fornat and send the mail @access public
ReplyTo( $address)
set the Reply-to header
Subject($subject, $a_add_prefix=false)
Define the subject line of the email.
__construct()
Mail contructor.
Organization( $org)
Organization( $org ) set the Organization header.
Body( $body, $charset="")
Body( text [, charset] ) set the body (message) of the mail define the charset if the message contain...
Receipt()
add a receipt to the mail ie.
To( $to)
set the mail recipient
Priority( $priority)
Priority( $priority ) set the mail priority $priority : integer taken between 1 (highest) and 5 ( low...
static makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen
PHPMailer - PHP email creation and transport class.