use wcf\system\background\job\EmailDeliveryBackgroundJob;
use wcf\system\background\BackgroundQueueHandler;
use wcf\system\email\mime\AbstractMimePart;
+use wcf\system\email\mime\IRecipientAwareMimePart;
use wcf\system\email\mime\TextMimePart;
use wcf\system\event\EventHandler;
use wcf\system\exception\SystemException;
}
}
+ /**
+ * Returns the text mime parts of this email.
+ *
+ * @return array<\wcf\system\email\mime\TextMimePart>
+ */
+ public function getText() {
+ return $this->text;
+ }
+
+ /**
+ * Returns the attachments (i.e. the mime parts that are not a TextMimePart) of this email.
+ *
+ * @return array<\wcf\system\email\mime\AbstractMimePart>
+ */
+ public function getAttachments() {
+ return $this->attachments;
+ }
+
/**
* Returns an array of [ name, value ] tuples representing the email's headers.
* Note: You must have set a Subject and at least one recipient, otherwise fetching the
$mail->addHeader('X-Community-Framework-Recipient', $recipient[1]->getUser()->username);
}
+ foreach (array_merge($mail->getText(), $mail->getAttachments()) as $mimePart) {
+ if ($mimePart[1] instanceof IRecipientAwareMimePart) $mimePart[1]->setRecipient($recipient[1]);
+ }
+
$data = [ 'mail' => $mail, 'recipient' => $recipient, 'skip' => false ];
EventHandler::getInstance()->fireAction($this, 'getJobs', $data);
--- /dev/null
+<?php
+namespace wcf\system\email\mime;
+use wcf\system\email\Mailbox;
+
+/**
+ * Represents a mime part that can be customized based in the recipient Mailbox.
+ *
+ * @author Tim Duesterhus
+ * @copyright 2001-2015 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.email.mime
+ * @category Community Framework
+ */
+interface IRecipientAwareMimePart {
+ /**
+ * Makes this mime part aware of it's recipient.
+ * Note: `null` is a valid parameter and denotes that this mime part should
+ * not be individualised.
+ *
+ * @param \wcf\system\email\Mailbox $mailbox
+ */
+ public function setRecipient(Mailbox $mailbox = null);
+}