78 throw new InvalidArgumentException(sprintf(
79 "The passed argument must be null or of type 'ilMailMimeTransport', %s given!",
84 self::$defaultTransport = $transport;
96 $subjectPrefix = $this->
settings->get(
'mail_subject_prefix');
97 if (
false === $subjectPrefix) {
100 if ($subjectPrefix !==
'') {
122 public function To($to) : void
127 $this->sendto[] = $to;
135 public function Cc($cc) : void
148 public function Bcc($bcc) : void
150 if (is_array($bcc)) {
153 $this->abcc[] = $bcc;
210 string $file_type =
'',
211 string $disposition =
'inline',
212 ?
string $display_name =
null
214 if ($file_type ===
'') {
215 $file_type =
'application/octet-stream';
219 $this->actype[] = $file_type;
220 $this->adispo[] = $disposition;
221 $this->adisplay[] = $display_name;
232 foreach ($this->aattach as $attachment) {
234 if (isset($this->adisplay[
$i]) && is_string($this->adisplay[
$i]) && $this->adisplay[
$i] !==
'') {
239 'path' => $attachment,
253 return array_values($this->images);
263 $this->finalBodyAlt =
'';
264 $this->finalBody =
'';
267 if (
$DIC->settings()->get(
'mail_send_html', 0)) {
268 $skin =
$DIC[
'ilClientIniFile']->readVariable(
'layout',
'skin');
270 $this->buildBodyMultiParts($skin);
271 $this->buildHtmlInlineImages($skin);
273 $this->finalBody = str_ireplace([
"<br />",
"<br>",
"<br/>"],
"\n", $this->body);
279 if ($this->body ===
'') {
283 if (strip_tags($this->body,
'<b><u><i><a>') === $this->body) {
285 $this->finalBodyAlt = $this->body;
289 $this->finalBodyAlt = strip_tags(str_ireplace([
"<br />",
"<br>",
"<br/>"],
"\n", $this->body));
292 $this->finalBody = str_replace(
'{PLACEHOLDER}', $this->body, $this->getHtmlEnvelope($skin));
297 $bracket_path =
'./Services/Mail/templates/default/tpl.html_mail_template.html';
299 if ($skin !==
'default') {
300 $tplpath =
'./Customizing/global/skin/' . $skin .
'/Services/Mail/tpl.html_mail_template.html';
302 if (file_exists($tplpath)) {
303 $bracket_path =
'./Customizing/global/skin/' . $skin .
'/Services/Mail/tpl.html_mail_template.html';
307 return file_get_contents($bracket_path);
312 $this->gatherImagesFromDirectory(
'./Services/Mail/templates/default/img');
314 if ($skin !==
'default') {
315 $skinDirectory =
'./Customizing/global/skin/' . $skin .
'/Services/Mail/img';
316 if (is_dir($skinDirectory) && is_readable($skinDirectory)) {
317 $this->gatherImagesFromDirectory($skinDirectory,
true);
322 protected function gatherImagesFromDirectory(
string $directory,
bool $clearPrevious =
false) : void
324 if ($clearPrevious) {
328 foreach (
new RegexIterator(
new DirectoryIterator($directory),
'/\.(jpg|svg|png)$/i') as $file) {
330 $cid =
'img/' . $file->getFilename();
332 $this->images[$cid] = [
333 'path' => $file->getPathname(),
335 'name' => $file->getFilename()
347 $transport = self::getDefaultTransport();
352 return $transport->send($this);
An exception for terminatinating execution or to throw for unit testing.
Subject(string $subject, bool $a_add_prefix=false)
Attach(string $filename, string $file_type='', string $disposition='inline', ?string $display_name=null)
Attach a file to the mail.
buildHtmlInlineImages(string $skin)
build()
Build the relevant email data.
Send(ilMailMimeTransport $transport=null)
Cc($cc)
Set the cc mail recipient.
buildBodyMultiParts(string $skin)
static getDefaultTransport()
static setDefaultTransport(?ilMailMimeTransport $transport)
To($to)
Set the mail recipient.
const MAIL_SUBJECT_PREFIX
Bcc($bcc)
Set the bcc mail recipient.
__construct()
ilMimeMail constructor.
From(ilMailMimeSender $sender)
getHtmlEnvelope(string $skin)
static makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Interface ilMailMimeTransport.
Interface ilMailMimeTransport.