ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilMimeMail Class Reference
+ Collaboration diagram for ilMimeMail:

Public Member Functions

 __construct (?MailBodyComposer $body_composer=null)
 
 Subject (string $subject, bool $add_prefix=false, string $context_prefix='')
 
 getSubject ()
 
 From (ilMailMimeSender $sender)
 
 To ($to)
 
 Cc ($cc)
 
 Bcc ($bcc)
 
 getTo ()
 
 getCc ()
 
 getBcc ()
 
 Body (string $body, ?Closure $to_html_transformation=null)
 
 getFinalBody ()
 
 getFinalBodyalt ()
 
 getFrom ()
 
 Attach (string $filename, string $file_type='', string $disposition='inline', ?string $display_name=null)
 
 AttachResource (ResourceIdentification $resource_identification, string $display_name, string $file_type='', string $disposition='inline')
 
 getMimeAttachments ()
 
 getAttachments ()
 
 getImages ()
 
 Send (?ilMailMimeTransport $transport=null)
 

Static Public Member Functions

static setDefaultTransport (?ilMailMimeTransport $transport)
 
static getDefaultTransport ()
 

Data Fields

final const string MAIL_SUBJECT_PREFIX = '[ILIAS]'
 

Protected Member Functions

 build ()
 

Protected Attributes

ilMailMimeSender $sender
 
ilMailMimeSubjectBuilder $subject_builder
 
ilSetting $settings
 
string $subject = ''
 
string $body = ''
 
string $final_body = ''
 
string $final_body_alt = ''
 
array $sendto = []
 
array $acc = []
 
array $abcc = []
 
InlineImages $images
 
array $mime_attachments = []
 

Static Protected Attributes

static ilMailMimeTransport $default_transport = null
 

Private Member Functions

 bodyComposer ()
 Resolved on demand, so that merely constructing a mail stays free of the services only its delivery format requires. More...
 

Private Attributes

MailBodyComposer $body_composer
 
Closure $to_html_transformation = null
 
readonly ILIAS DI Container $dic
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilMimeMail::__construct ( ?MailBodyComposer  $body_composer = null)

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

55 {
56 global $DIC;
57
58 $this->dic = $DIC;
59
60 $this->settings = $this->dic->settings();
61
62 if (!(self::getDefaultTransport() instanceof ilMailMimeTransport)) {
63 $factory = $DIC->mail()->mime()->transportFactory();
64 self::setDefaultTransport($factory->getTransport());
65 }
66
67 $this->subject_builder = new ilMailMimeSubjectBuilder($this->settings, self::MAIL_SUBJECT_PREFIX);
68 $this->body_composer = $body_composer;
69 $this->images = InlineImages::none();
70 }
static setDefaultTransport(?ilMailMimeTransport $transport)
MailBodyComposer $body_composer
global $DIC
Definition: shib_login.php:26

References $body_composer, $DIC, setDefaultTransport(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ Attach()

ilMimeMail::Attach ( string  $filename,
string  $file_type = '',
string  $disposition = 'inline',
?string  $display_name = null 
)
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 | null$display_nameFilename to use in email (if different from source file)

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

202 : void {
203 $this->mime_attachments[] = MailMimeAttachment::fromPath(
204 $filename,
205 $file_type,
206 $disposition,
207 $display_name
208 );
209 }
$filename
Definition: buildRTE.php:78

◆ AttachResource()

ilMimeMail::AttachResource ( ResourceIdentification  $resource_identification,
string  $display_name,
string  $file_type = '',
string  $disposition = 'inline' 
)

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

216 : void {
217 $this->mime_attachments[] = MailMimeAttachment::fromResource(
218 $resource_identification,
219 $display_name,
220 $file_type,
221 $disposition
222 );
223 }

◆ Bcc()

ilMimeMail::Bcc (   $bcc)
Parameters
string | string[]$bccBCC email address, accept both a single address or an array of addresses

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

133 : void
134 {
135 if (is_array($bcc)) {
136 $this->abcc = $bcc;
137 } else {
138 $this->abcc[] = $bcc;
139 }
140 }

◆ Body()

ilMimeMail::Body ( string  $body,
?Closure  $to_html_transformation = null 
)
Parameters
Closure(string)string|null $to_html_transformation

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

169 : void
170 {
171 $this->body = $body;
172 $this->to_html_transformation = $to_html_transformation;
173 }
Closure $to_html_transformation

References $body, and $to_html_transformation.

◆ bodyComposer()

ilMimeMail::bodyComposer ( )
private

Resolved on demand, so that merely constructing a mail stays free of the services only its delivery format requires.

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

77 {
78 return $this->body_composer ??= $this->dic->mail()->mime()->bodyComposer();
79 }

◆ build()

ilMimeMail::build ( )
protected

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

260 : void
261 {
262 $composed = $this->bodyComposer()->compose(
263 new MailBodySource($this->body, $this->to_html_transformation)
264 );
265
266 $this->final_body = $composed->body();
267 $this->final_body_alt = $composed->alternativeBody() ?? '';
268 $this->images = $composed->images();
269 }
bodyComposer()
Resolved on demand, so that merely constructing a mail stays free of the services only its delivery f...

◆ Cc()

ilMimeMail::Cc (   $cc)
Parameters
string | string[]$ccCC email address, accept both a single address or an array of addresses

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

121 : void
122 {
123 if (is_array($cc)) {
124 $this->acc = $cc;
125 } else {
126 $this->acc[] = $cc;
127 }
128 }

◆ From()

ilMimeMail::From ( ilMailMimeSender  $sender)

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

101 : void
102 {
103 $this->sender = $sender;
104 }
ilMailMimeSender $sender

References $sender.

◆ getAttachments()

ilMimeMail::getAttachments ( )
Returns
array{path: string, name: string}[]
Deprecated:
Use getMimeAttachments() for path and IRSS attachments.

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

237 : array
238 {
239 $attachments = [];
240
241 foreach ($this->mime_attachments as $attachment) {
242 if ($attachment->isResource() || $attachment->getPath() === null) {
243 continue;
244 }
245
246 $attachments[] = [
247 'path' => $attachment->getPath(),
248 'name' => $attachment->getDisplayName(),
249 ];
250 }
251
252 return $attachments;
253 }

◆ getBcc()

ilMimeMail::getBcc ( )
Returns
string[]

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

161 : array
162 {
163 return $this->abcc;
164 }

References $abcc.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getCc()

ilMimeMail::getCc ( )
Returns
string[]

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

153 : array
154 {
155 return $this->acc;
156 }

References $acc.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getDefaultTransport()

static ilMimeMail::getDefaultTransport ( )
static

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

87 {
89 }
static ilMailMimeTransport $default_transport

References $default_transport.

◆ getFinalBody()

ilMimeMail::getFinalBody ( )

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

175 : string
176 {
177 return $this->final_body;
178 }
string $final_body

References $final_body.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getFinalBodyalt()

ilMimeMail::getFinalBodyalt ( )

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

180 : string
181 {
183 }
string $final_body_alt

References $final_body_alt.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getFrom()

ilMimeMail::getFrom ( )

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

References $sender.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getImages()

ilMimeMail::getImages ( )

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

256 {
257 return $this->images;
258 }
InlineImages $images

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getMimeAttachments()

ilMimeMail::getMimeAttachments ( )
Returns
list<MailMimeAttachment>

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

228 : array
229 {
231 }
array $mime_attachments

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getSubject()

ilMimeMail::getSubject ( )

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

96 : string
97 {
98 return $this->subject;
99 }

References $subject.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ getTo()

ilMimeMail::getTo ( )
Returns
string[]

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

145 : array
146 {
147 return $this->sendto;
148 }

References $sendto.

Referenced by ilMailMimeTransportBase\send().

+ Here is the caller graph for this function:

◆ Send()

ilMimeMail::Send ( ?ilMailMimeTransport  $transport = null)

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

271 : bool
272 {
273 if (!($transport instanceof ilMailMimeTransport)) {
274 $transport = self::getDefaultTransport();
275 }
276
277 $this->build();
278
279 return $transport->send($this);
280 }
static getDefaultTransport()

◆ setDefaultTransport()

static ilMimeMail::setDefaultTransport ( ?ilMailMimeTransport  $transport)
static

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

81 : void
82 {
83 self::$default_transport = $transport;
84 }

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

+ Here is the caller graph for this function:

◆ Subject()

ilMimeMail::Subject ( string  $subject,
bool  $add_prefix = false,
string  $context_prefix = '' 
)

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

91 : void
92 {
93 $this->subject = $this->subject_builder->subject($subject, $add_prefix, $context_prefix);
94 }

References $subject.

◆ To()

ilMimeMail::To (   $to)
Parameters
string | string[]$toTo email address, accept both a single address or an array of addresses

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

109 : void
110 {
111 if (is_array($to)) {
112 $this->sendto = $to;
113 } else {
114 $this->sendto[] = $to;
115 }
116 }

Field Documentation

◆ $abcc

array ilMimeMail::$abcc = []
protected

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

Referenced by getBcc().

◆ $acc

array ilMimeMail::$acc = []
protected

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

Referenced by getCc().

◆ $body

string ilMimeMail::$body = ''
protected

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

Referenced by Body().

◆ $body_composer

MailBodyComposer ilMimeMail::$body_composer
private

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

Referenced by __construct().

◆ $default_transport

ilMailMimeTransport ilMimeMail::$default_transport = null
staticprotected

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

Referenced by getDefaultTransport().

◆ $dic

readonly ILIAS DI Container ilMimeMail::$dic
private

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

◆ $final_body

string ilMimeMail::$final_body = ''
protected

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

Referenced by getFinalBody().

◆ $final_body_alt

string ilMimeMail::$final_body_alt = ''
protected

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

Referenced by getFinalBodyalt().

◆ $images

InlineImages ilMimeMail::$images
protected

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

◆ $mime_attachments

array ilMimeMail::$mime_attachments = []
protected

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

◆ $sender

ilMailMimeSender ilMimeMail::$sender
protected

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

Referenced by From(), and getFrom().

◆ $sendto

array ilMimeMail::$sendto = []
protected

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

Referenced by getTo().

◆ $settings

ilSetting ilMimeMail::$settings
protected

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

◆ $subject

string ilMimeMail::$subject = ''
protected

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

Referenced by getSubject(), and Subject().

◆ $subject_builder

ilMailMimeSubjectBuilder ilMimeMail::$subject_builder
protected

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

◆ $to_html_transformation

Closure ilMimeMail::$to_html_transformation = null
private

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

Referenced by Body().

◆ MAIL_SUBJECT_PREFIX

final const string ilMimeMail::MAIL_SUBJECT_PREFIX = '[ILIAS]'

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

Referenced by ilObjMailGUI\populateExternalSettingsForm().


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