66 $factory = $DIC[
"mail.mime.transport.factory"];
67 self::setDefaultTransport(
$factory->getTransport());
79 "The passed argument must be null or of type 'ilMailMimeTransport', %s given!",
84 self::$defaultTransport = $transport;
89 return self::$defaultTransport;
96 $subjectPrefix = $this->
settings->get(
'mail_subject_prefix');
97 if (
false === $subjectPrefix) {
98 $subjectPrefix = self::MAIL_SUBJECT_PREFIX;
100 if ($subjectPrefix !==
'') {
101 $subject = $subjectPrefix .
' ' .
$subject;
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');
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) {
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);
buildHtmlInlineImages(string $skin)
Subject(string $subject, bool $a_add_prefix=false)
getHtmlEnvelope(string $skin)
Send(ilMailMimeTransport $transport=null)
Cc($cc)
Set the cc mail recipient.
static setDefaultTransport(?ilMailMimeTransport $transport)
__construct()
ilMimeMail constructor.
Bcc($bcc)
Set the bcc mail recipient.
static getDefaultTransport()
Interface ilMailMimeTransport.
Interface ilMailMimeTransport.
buildBodyMultiParts(string $skin)
static makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen
build()
Build the relevant email data.
To($to)
Set the mail recipient.
const MAIL_SUBJECT_PREFIX
From(ilMailMimeSender $sender)
Attach(string $filename, string $file_type='', string $disposition='inline', ?string $display_name=null)
Attach a file to the mail.