19 declare(strict_types=1);
60 $factory = $DIC->mail()->mime()->transportFactory();
61 self::setDefaultTransport($factory->getTransport());
70 self::$defaultTransport = $transport;
75 return self::$defaultTransport;
78 public function Subject(
string $subject,
bool $addPrefix =
false,
string $contextPrefix =
''): void
80 $this->subject = $this->subjectBuilder->subject($subject, $addPrefix, $contextPrefix);
96 public function To($to): void
101 $this->sendto[] = $to;
108 public function Cc($cc): void
120 public function Bcc($bcc): void
122 if (is_array($bcc)) {
125 $this->abcc[] = $bcc;
153 public function Body(
string $body): void
182 string $file_type =
'',
183 string $disposition =
'inline',
184 ?
string $display_name =
null 186 if ($file_type ===
'') {
187 $file_type =
'application/octet-stream';
191 $this->actype[] = $file_type;
192 $this->adispo[] = $disposition;
193 $this->adisplay[] = $display_name;
204 foreach ($this->aattach as $attachment) {
206 if (isset($this->adisplay[$i]) && is_string($this->adisplay[$i]) && $this->adisplay[$i] !==
'') {
207 $name = $this->adisplay[$i];
211 'path' => $attachment,
226 return array_values($this->images);
233 $this->finalBodyAlt =
'';
234 $this->finalBody =
'';
237 if ($DIC->settings()->get(
'mail_send_html',
'0')) {
238 $skin = $DIC[
'ilClientIniFile']->readVariable(
'layout',
'skin');
239 $style = $DIC[
'ilClientIniFile']->readVariable(
'layout',
'style');
250 $maybeHTML = str_ireplace([
'<br />',
'<br>',
'<br/>'],
"\n", $maybeHTML);
252 return strip_tags($maybeHTML);
257 if ($this->body ===
'') {
261 if (strip_tags($this->body,
'<b><u><i><a>') === $this->body) {
265 $this->finalBodyAlt = strip_tags($this->body);
266 $this->body = $this->
refinery->string()->makeClickable()->transform(nl2br($this->body));
269 $this->finalBodyAlt = strip_tags(str_ireplace([
"<br />",
"<br>",
"<br/>"],
"\n", $this->body));
272 $this->finalBody = str_replace(
'{PLACEHOLDER}', $this->body, $this->
getHtmlEnvelope($skin, $style));
277 return realpath(dirname(__DIR__, 4) .
'/');
282 $bracket_path = $this->
getPathToRootDirectory() .
'/components/ILIAS/Mail/templates/default/tpl.html_mail_template.html';
283 if ($skin !==
'default') {
291 ) .
'/public/Customizing/skin/' . $location .
'/components/ILIAS/Mail/tpl.html_mail_template.html';
292 if (is_file($custom_path)) {
293 $bracket_path = $custom_path;
299 return file_get_contents($bracket_path);
304 $this->gatherImagesFromDirectory(
308 if ($skin !==
'default') {
316 ) .
'/public/Customizing/skin/' . $location .
'/components/ILIAS/Mail/img';
317 if (is_dir($custom_directory) && is_readable($custom_directory)) {
318 $this->gatherImagesFromDirectory($custom_directory,
true);
325 protected function gatherImagesFromDirectory(
string $directory,
bool $clearPrevious =
false):
void 327 if ($clearPrevious) {
331 foreach (
new RegexIterator(
333 '/\.(jpg|jpeg|gif|svg|png)$/i' 336 $cid =
'img/' . $file->getFilename();
338 $this->images[$cid] = [
339 'path' => $file->getPathname(),
341 'name' => $file->getFilename()
349 $transport = self::getDefaultTransport();
354 return $transport->send($this);
buildBodyMultiParts(string $skin, string $style)
Send(?ilMailMimeTransport $transport=null)
removeHTMLTags(string $maybeHTML)
Class ilMailMimeSubjectBuilder.
Subject(string $subject, bool $addPrefix=false, string $contextPrefix='')
static setDefaultTransport(?ilMailMimeTransport $transport)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getDefaultTransport()
getHtmlEnvelope(string $skin, string $style)
buildHtmlInlineImages(string $skin, string $style)
Interface ilMailMimeTransport.
readonly Refinery $refinery
Interface ilMailMimeTransport.
ilMailMimeSubjectBuilder $subjectBuilder
static ilMailMimeTransport $defaultTransport
From(ilMailMimeSender $sender)
final const MAIL_SUBJECT_PREFIX
Attach(string $filename, string $file_type='', string $disposition='inline', ?string $display_name=null)