1 <?php declare(strict_types=1);
31 $mail =
new PHPMailer();
75 foreach ($mail->
getTo() as $recipients) {
76 $recipient_pieces = array_filter(array_map(
'trim', explode(
',', $recipients)));
77 foreach ($recipient_pieces as $recipient) {
78 if (!$this->
getMailer()->AddAddress($recipient,
'')) {
84 foreach ($mail->
getCc() as $carbon_copies) {
85 $cc_pieces = array_filter(array_map(
'trim', explode(
',', $carbon_copies)));
86 foreach ($cc_pieces as $carbon_copy) {
87 if (!$this->
getMailer()->AddCC($carbon_copy,
'')) {
93 foreach ($mail->
getBcc() as $blind_carbon_copies) {
94 $bcc_pieces = array_filter(array_map(
'trim', explode(
',', $blind_carbon_copies)));
95 foreach ($bcc_pieces as $blind_carbon_copy) {
96 if (!$this->
getMailer()->AddBCC($blind_carbon_copy,
'')) {
104 if ($mail->
getFrom()->hasReplyToAddress()) {
105 if (!$this->
getMailer()->addReplyTo($mail->
getFrom()->getReplyToAddress(), $mail->
getFrom()->getReplyToName())) {
109 if ($mail->
getFrom()->hasEnvelopFromAddress()) {
113 if (!$this->
getMailer()->setFrom($mail->
getFrom()->getFromAddress(), $mail->
getFrom()->getFromName(),
false)) {
118 if (!$this->
getMailer()->AddAttachment($attachment[
'path'], $attachment[
'name'])) {
124 if (!$this->
getMailer()->AddEmbeddedImage($image[
'path'], $image[
'cid'], $image[
'name'])) {
140 "Trying to delegate external email delivery:" .
141 " Initiated by: %s (%s) " .
142 "| To: %s | CC: %s | BCC: %s | Subject: %s " .
144 "| ReplyTo: %s / %s " .
145 "| EnvelopeFrom: %s",
148 implode(
', ', $mail->
getTo()),
149 implode(
', ', $mail->
getCc()),
150 implode(
', ', $mail->
getBcc()),
152 $mail->
getFrom()->getFromAddress(),
153 $mail->
getFrom()->getFromName(),
154 $mail->
getFrom()->getReplyToAddress(),
155 $mail->
getFrom()->getReplyToName(),
156 $mail->
getFrom()->getEnvelopFromAddress()
164 $this->mailer->SMTPDebug = 4;
165 $this->mailer->Debugoutput =
function (
$message, $level) {
167 strpos(
$message,
'Invalid address') !==
false ||
168 strpos(
$message,
'Message body empty') !== false
180 'Successfully delegated external mail delivery' 183 if (strlen($this->
getMailer()->ErrorInfo) > 0) {
185 '... with most recent errors: %s',
191 'Could not deliver external email: %s',
196 $this->eventHandler->raise(
'Services/Mail',
'externalEmailDelegated', [
setMailer(PHPMailer $mailer)
send(ilMimeMail $mail)
bool
__construct(ilSetting $settings, ilAppEventHandler $eventHandler)
ilMailMimeTransportBase constructor.
Interface ilMailMimeTransport.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Class ilMailMimeTransportBase.
static getLogger($a_component_id)
Get component logger.