ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilMimeMail Class Reference

Class ilMimeMail. More...

+ Collaboration diagram for ilMimeMail:

Public Member Functions

 __construct ()
 ilMimeMail constructor. More...
 
 Subject ($subject, $a_add_prefix=false)
 
 getSubject ()
 
 From (ilMailMimeSender $sender)
 
 To ($to)
 Set the mail recipient. More...
 
 Cc ($cc)
 Set the cc mail recipient. More...
 
 Bcc ($bcc)
 Set the bcc mail recipient. More...
 
 getTo ()
 
 getCc ()
 
 getBcc ()
 
 Body ($body)
 
 getFinalBody ()
 
 getFinalBodyAlt ()
 
 getFrom ()
 
 Attach ($filename, $file_type='', $disposition='inline', $display_name=null)
 Attach a file to the mail. More...
 
 getAttachments ()
 
 getImages ()
 
 Send ($transport=null)
 

Static Public Member Functions

static setDefaultTransport ($transport)
 
static getDefaultTransport ()
 

Protected Member Functions

 build ()
 Build the relevant email data. More...
 
 buildBodyParts ($skin)
 
 getHtmlEnvelope ($skin)
 
 buildHtmlInlineImages ($skin)
 

Protected Attributes

 $subject = ''
 
 $body = ''
 
 $finalBody = ''
 
 $finalBodyAlt = ''
 
 $sendto = array()
 
 $acc = array()
 
 $abcc = array()
 
 $images = array()
 
 $aattach = array()
 
 $actype = array()
 
 $adispo = array()
 
 $adisplay = array()
 
 $sender
 

Static Protected Attributes

static $defaultTransport
 

Detailed Description

Class ilMimeMail.

Definition at line 7 of file class.ilMimeMail.php.

Constructor & Destructor Documentation

◆ __construct()

ilMimeMail::__construct ( )

ilMimeMail constructor.

Definition at line 84 of file class.ilMimeMail.php.

85 {
86 global $DIC;
87
88 if (!(self::getDefaultTransport() instanceof \ilMailMimeTransport)) {
89 $factory = $DIC["mail.mime.transport.factory"];
90 self::setDefaultTransport($factory->getTransport());
91 }
92 }
$factory
Definition: metadata.php:47
static setDefaultTransport($transport)
Interface ilMailMimeTransport.
global $DIC
Definition: saml.php:7

References $DIC, $factory, and setDefaultTransport().

+ Here is the call graph for this function:

Member Function Documentation

◆ Attach()

ilMimeMail::Attach (   $filename,
  $file_type = '',
  $disposition = 'inline',
  $display_name = null 
)

Attach a file to the mail.

Parameters
string$filenamePath of the file to attach
string$file_typeMIME-type of the file. default to 'application/x-unknown-content-type'
string$dispositionInstruct the Mailclient to display the file if possible ("inline") or always as a link ("attachment") possible values are "inline", "attachment"
string$display_nameFilename to use in email (if different from source file)

Definition at line 254 of file class.ilMimeMail.php.

255 {
256 if ($file_type == '') {
257 $file_type = 'application/octet-stream';
258 }
259
260 $this->aattach[] = $filename;
261 $this->actype[] = $file_type;
262 $this->adispo[] = $disposition;
263 $this->adisplay[] = $display_name;
264 }

References $filename.

◆ Bcc()

ilMimeMail::Bcc (   $bcc)

Set the bcc mail recipient.

Parameters
string|arrayBCC email address, accept both a single address or an array of addresses

Definition at line 182 of file class.ilMimeMail.php.

183 {
184 if (is_array($bcc)) {
185 $this->abcc = $bcc;
186 } else {
187 $this->abcc[] = $bcc;
188 }
189 }

◆ Body()

ilMimeMail::Body (   $body)
Parameters
string$body

Definition at line 218 of file class.ilMimeMail.php.

219 {
220 $this->body = $body;
221 }

References $body.

◆ build()

ilMimeMail::build ( )
protected

Build the relevant email data.

Definition at line 301 of file class.ilMimeMail.php.

302 {
303 global $DIC;
304
305 $this->finalBodyAlt = '';
306 $this->finalBody = '';
307 $this->images = array();
308
309 if ($DIC->settings()->get('mail_send_html', 0)) {
310 $skin = $DIC['ilClientIniFile']->readVariable('layout', 'skin');
311
312 $this->buildBodyParts($skin);
313 $this->buildHtmlInlineImages($skin);
314 } else {
315 $this->finalBody = $this->body;
316 }
317 }
buildHtmlInlineImages($skin)
buildBodyParts($skin)

References $body, $DIC, buildBodyParts(), and buildHtmlInlineImages().

Referenced by Send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildBodyParts()

ilMimeMail::buildBodyParts (   $skin)
protected
Parameters
string$skin

Definition at line 322 of file class.ilMimeMail.php.

323 {
324 if (0 == strlen($this->body)) {
325 $this->body = ' ';
326 }
327
328 if (strip_tags($this->body, '<b><u><i><a>') == $this->body) {
329 // Let's assume(!) that there is no HTML (except certain tags, e.g. used for object title formatting, where the consumer is not aware of this), so convert "\n" to "<br>"
330 $this->finalBodyAlt = $this->body;
331 $this->body = \ilUtil::makeClickable(nl2br($this->body));
332 } else {
333 // if there is HTML, convert "<br>" to "\n" and strip tags for plain text alternative
334 $this->finalBodyAlt = strip_tags(str_ireplace(array("<br />", "<br>", "<br/>"), "\n", $this->body));
335 }
336
337 $this->finalBody = str_replace('{PLACEHOLDER}', $this->body, $this->getHtmlEnvelope($skin));
338 }
getHtmlEnvelope($skin)
static makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen

References $body, getHtmlEnvelope(), and ilUtil\makeClickable().

Referenced by build().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildHtmlInlineImages()

ilMimeMail::buildHtmlInlineImages (   $skin)
protected
Parameters
string$skin

Definition at line 362 of file class.ilMimeMail.php.

363 {
364 $this->gatherImagesFromDirectory('./Services/Mail/templates/default/img');
365
366 if ($skin != 'default') {
367 $skinDirectory = './Customizing/global/skin/' . $skin . '/Services/Mail/img';
368 if (is_dir($skinDirectory) && is_readable($skinDirectory)) {
369 $this->gatherImagesFromDirectory($skinDirectory, true);
370 }
371 }
372 }

Referenced by build().

+ Here is the caller graph for this function:

◆ Cc()

ilMimeMail::Cc (   $cc)

Set the cc mail recipient.

Parameters
string|arrayCC email address, accept both a single address or an array of addresses

Definition at line 169 of file class.ilMimeMail.php.

170 {
171 if (is_array($cc)) {
172 $this->acc = $cc;
173 } else {
174 $this->acc[] = $cc;
175 }
176 }

◆ From()

ilMimeMail::From ( ilMailMimeSender  $sender)
Parameters
ilMailMimeSender$sender

Definition at line 147 of file class.ilMimeMail.php.

148 {
149 $this->sender = $sender;
150 }

References $sender.

◆ getAttachments()

ilMimeMail::getAttachments ( )
Returns
array An array of attachments. Each element must container to associative keys, 'path' and 'name'

Definition at line 269 of file class.ilMimeMail.php.

270 {
271 $attachments = array();
272
273 $i = 0;
274 foreach ($this->aattach as $attachment) {
275 $name = '';
276 if (isset($this->adisplay[$i]) && strlen($this->adisplay[$i]) > 0) {
277 $name = $this->adisplay[$i];
278 }
279
280 $attachments[] = array(
281 'path' => $attachment,
282 'name' => $name
283 );
284 ++$i;
285 }
286
287 return $attachments;
288 }
$i
Definition: disco.tpl.php:19
if($format !==null) $name
Definition: metadata.php:146

References $i, and $name.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getBcc()

ilMimeMail::getBcc ( )
Returns
array

Definition at line 210 of file class.ilMimeMail.php.

211 {
212 return $this->abcc;
213 }

References $abcc.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getCc()

ilMimeMail::getCc ( )
Returns
array

Definition at line 202 of file class.ilMimeMail.php.

203 {
204 return $this->acc;
205 }

References $acc.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getDefaultTransport()

static ilMimeMail::getDefaultTransport ( )
static
Returns
\ilMailMimeTransport|null

Definition at line 113 of file class.ilMimeMail.php.

114 {
116 }
static $defaultTransport

References $defaultTransport.

Referenced by Send().

+ Here is the caller graph for this function:

◆ getFinalBody()

ilMimeMail::getFinalBody ( )
Returns
string

Definition at line 226 of file class.ilMimeMail.php.

227 {
228 return $this->finalBody;
229 }

References $finalBody.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getFinalBodyAlt()

ilMimeMail::getFinalBodyAlt ( )
Returns
string

Definition at line 234 of file class.ilMimeMail.php.

235 {
236 return $this->finalBodyAlt;
237 }

References $finalBodyAlt.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getFrom()

ilMimeMail::getFrom ( )
Returns
ilMailMimeSender

Definition at line 242 of file class.ilMimeMail.php.

243 {
244 return $this->sender;
245 }

References $sender.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getHtmlEnvelope()

ilMimeMail::getHtmlEnvelope (   $skin)
protected
Parameters
string$skin
Returns
string

Definition at line 344 of file class.ilMimeMail.php.

345 {
346 $bracket_path = './Services/Mail/templates/default/tpl.html_mail_template.html';
347
348 if ($skin != 'default') {
349 $tplpath = './Customizing/global/skin/' . $skin . '/Services/Mail/tpl.html_mail_template.html';
350
351 if (file_exists($tplpath)) {
352 $bracket_path = './Customizing/global/skin/' . $skin . '/Services/Mail/tpl.html_mail_template.html';
353 }
354 }
355
356 return file_get_contents($bracket_path);
357 }

Referenced by buildBodyParts().

+ Here is the caller graph for this function:

◆ getImages()

ilMimeMail::getImages ( )
Returns
array An array of images. Each element must container to associative keys, 'path', 'cid' and 'name'

Definition at line 293 of file class.ilMimeMail.php.

294 {
295 return array_values($this->images);
296 }

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getSubject()

ilMimeMail::getSubject ( )
Returns
string

Definition at line 139 of file class.ilMimeMail.php.

140 {
141 return $this->subject;
142 }

References $subject.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getTo()

ilMimeMail::getTo ( )
Returns
array

Definition at line 194 of file class.ilMimeMail.php.

195 {
196 return $this->sendto;
197 }

References $sendto.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ Send()

ilMimeMail::Send (   $transport = null)
Parameters
$transport\ilMailMimeTransport|null
Returns
bool A boolean flag whether or not the transport might be successful

Definition at line 402 of file class.ilMimeMail.php.

403 {
404 if (!($transport instanceof \ilMailMimeTransport)) {
405 $transport = self::getDefaultTransport();
406 }
407
408 $this->build();
409
410 return $transport->send($this);
411 }
build()
Build the relevant email data.
static getDefaultTransport()

References build(), and getDefaultTransport().

+ Here is the call graph for this function:

◆ setDefaultTransport()

static ilMimeMail::setDefaultTransport (   $transport)
static
Parameters
\ilMailMimeTransport | null$transport
Exceptions

InvalidArgumentException

Definition at line 98 of file class.ilMimeMail.php.

99 {
100 if (!is_null($transport) && !($transport instanceof \ilMailMimeTransport)) {
101 throw new \InvalidArgumentException(\sprintf(
102 "The passed argument must be null or of type 'ilMailMimeTransport', %s given!",
103 gettype($transport)
104 ));
105 }
106
107 self::$defaultTransport = $transport;
108 }
sprintf('%.4f', $callTime)

References sprintf.

Referenced by __construct(), and ilMailMimeTest\setUp().

+ Here is the caller graph for this function:

◆ Subject()

ilMimeMail::Subject (   $subject,
  $a_add_prefix = false 
)
Parameters
string$subjectDefine the subject line of the email
bool$a_add_prefix

Definition at line 122 of file class.ilMimeMail.php.

123 {
124 if ($a_add_prefix) {
125 // #9096
126 require_once 'Services/Mail/classes/class.ilMail.php';
127 $prefix = ilMail::getSubjectPrefix();
128 if (trim($prefix)) {
129 $subject = trim($prefix) . ' ' . $subject;
130 }
131 }
132
133 $this->subject = $subject;
134 }
static getSubjectPrefix()
Get text that will be prepended to auto generated mails.

References $subject, and ilMail\getSubjectPrefix().

+ Here is the call graph for this function:

◆ To()

ilMimeMail::To (   $to)

Set the mail recipient.

Parameters
string|arrayTo email address, accept both a single address or an array of addresses

Definition at line 156 of file class.ilMimeMail.php.

157 {
158 if (is_array($to)) {
159 $this->sendto = $to;
160 } else {
161 $this->sendto[] = $to;
162 }
163 }

Field Documentation

◆ $aattach

ilMimeMail::$aattach = array()
protected

Definition at line 59 of file class.ilMimeMail.php.

◆ $abcc

ilMimeMail::$abcc = array()
protected

Definition at line 48 of file class.ilMimeMail.php.

Referenced by getBcc().

◆ $acc

ilMimeMail::$acc = array()
protected

Definition at line 43 of file class.ilMimeMail.php.

Referenced by getCc().

◆ $actype

ilMimeMail::$actype = array()
protected

Definition at line 64 of file class.ilMimeMail.php.

◆ $adisplay

ilMimeMail::$adisplay = array()
protected

Definition at line 74 of file class.ilMimeMail.php.

◆ $adispo

ilMimeMail::$adispo = array()
protected

Definition at line 69 of file class.ilMimeMail.php.

◆ $body

ilMimeMail::$body = ''
protected

Definition at line 22 of file class.ilMimeMail.php.

Referenced by Body(), build(), and buildBodyParts().

◆ $defaultTransport

ilMimeMail::$defaultTransport
staticprotected

Definition at line 12 of file class.ilMimeMail.php.

Referenced by getDefaultTransport().

◆ $finalBody

ilMimeMail::$finalBody = ''
protected

Definition at line 27 of file class.ilMimeMail.php.

Referenced by getFinalBody().

◆ $finalBodyAlt

ilMimeMail::$finalBodyAlt = ''
protected

Definition at line 32 of file class.ilMimeMail.php.

Referenced by getFinalBodyAlt().

◆ $images

ilMimeMail::$images = array()
protected

Definition at line 53 of file class.ilMimeMail.php.

◆ $sender

ilMimeMail::$sender
protected

Definition at line 79 of file class.ilMimeMail.php.

Referenced by From(), and getFrom().

◆ $sendto

ilMimeMail::$sendto = array()
protected

Definition at line 38 of file class.ilMimeMail.php.

Referenced by getTo().

◆ $subject

ilMimeMail::$subject = ''
protected

Definition at line 17 of file class.ilMimeMail.php.

Referenced by getSubject(), and Subject().


The documentation for this class was generated from the following file: