</style>
</head>
<body>
+ {if $beforeContent|isset}{@$beforeContent}{/if}
<div class="content">
{@$content}
</div>
+ {if $afterContent|isset}{@$afterContent}{/if}
{capture assign='footer'}
{hascontent}
<span style="font-size: 0;">-- <br></span>
--- /dev/null
+{if $mimeType === 'text/plain'}
+{capture assign='content'}
+{lang}wcf.user.notification.mail.plaintext.intro{/lang}
+
+{@$notificationContent}
+
+{lang}wcf.user.notification.mail.plaintext.outro{/lang}
+{/capture}
+{include file='email_plaintext'}
+{else}
+ {capture assign='content'}
+ <h1>{lang}wcf.user.notification.mail.html.headline{/lang}</h1>
+ {lang}wcf.user.notification.mail.html.intro{/lang}
+
+ {@$notificationContent}
+
+ {lang}wcf.user.notification.mail.html.outro{/lang}
+ {/capture}
+ {include file='email_html'}
+{/if}
+{if $beforeContent|isset}{@$beforeContent}{/if}
+
{@$content}
+
+{if $afterContent|isset}{@$afterContent}{/if}
{hascontent} {* this line ends with a space *}
-- {* this line ends with a space *}
* @param string $mimeType Mime type to provide in the email. You *must* not provide a charset. UTF-8 will be used automatically.
* @param string $template Template to evaluate
* @param string $application Application of the template to evaluate (default: wcf)
- * @param string $content Content of this text part (this is passed to the template).
+ * @param mixed $content Content of this text part. Passend as 'content' to the template. If it is an array it will additionally be merged with the template variables.
*/
- public function __construct($mimeType, $template, $application = 'wcf', $content = '') {
+ public function __construct($mimeType, $template, $application = 'wcf', $content = null) {
parent::__construct($content, $mimeType);
$this->template = $template;
protected function getTemplateVariables() {
$styleCache = StyleCacheBuilder::getInstance()->getData();
- return [
+ $result = [
'content' => $this->content,
'mimeType' => $this->mimeType,
'mailbox' => $this->mailbox,
'style' => new ActiveStyle($styleCache['styles'][$styleCache['default']])
];
+
+ if (is_array($this->content)) {
+ return array_merge($result, $this->content);
+ }
+
+ return $result;
}
}
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\event\EventHandler;
use wcf\system\exception\SystemException;
-use wcf\system\mail\Mail;
+use wcf\system\email\mime\AbstractMimePart;
+use wcf\system\email\mime\RecipientAwareTextMimePart;
+use wcf\system\email\Email;
+use wcf\system\email\UserMailbox;
use wcf\system\user\notification\event\IUserNotificationEvent;
use wcf\system\user\notification\object\type\IUserNotificationObjectType;
use wcf\system\user\notification\object\IUserNotificationObject;
use wcf\system\user\storage\UserStorageHandler;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
-use wcf\util\StringUtil;
+use wcf\util\CryptoUtil;
/**
* Handles user notifications.
$event->setLanguage($user->getLanguage());
WCF::setLanguage($user->getLanguage()->languageID);
- // add mail header
- $message = $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.header', [
- 'user' => $user
- ])."\n\n";
-
- // get message
- $message .= $event->getEmailMessage();
-
- // append notification mail footer
- $token = $user->notificationMailToken;
- if (!$token) {
- // generate token if not present
- $token = mb_substr(StringUtil::getHash(serialize([$user->userID, StringUtil::getRandomID()])), 0, 20);
+ // generate token if not present
+ if (!$user->notificationMailToken) {
+ $token = bin2hex(CryptoUtil::randomBytes(10));
$editor = new UserEditor($user);
$editor->update(['notificationMailToken' => $token]);
+
+ // reload user
+ $user = new User($user->userID);
}
- $message .= "\n\n".$user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.footer', [
- 'user' => $user,
- 'token' => $token,
- 'notification' => $notification
- ]);
-
- // build mail
- $mail = new Mail([$user->username => $user->email], $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.subject', ['title' => $event->getEmailTitle()]), $message);
- $mail->setLanguage($user->getLanguage());
- $mail->send();
+
+ $email = new Email();
+ $email->setSubject($user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.subject', [
+ 'title' => $event->getEmailTitle()
+ ]));
+ $email->addRecipient(new UserMailbox($user));
+
+ $message = $event->getEmailMessage('instant');
+ if ($message instanceof AbstractMimePart) {
+ $email->setBody($message);
+ }
+ else {
+ $email->setBody(new RecipientAwareTextMimePart('text/plain', 'email_notification', 'wcf', [
+ 'notificationContent' => $message,
+ 'event' => $event
+ ]));
+ }
+
+ $email->send();
}
/**
<item name="wcf.user.notification.follow.mail"><![CDATA[{@$author->username} folgt {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if}.]]></item>
<item name="wcf.user.notification.follow.mail.stacked"><![CDATA[{if $count < 4}{@$authors[0]->username}{if $count == 2} und {else}, {/if}{@$authors[1]->username}{if $count == 3} und {@$authors[2]->username}{/if}{else}{@$authors[0]->username} und {#$others} weiteren{/if} folgen {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if}.]]></item>
<item name="wcf.user.notification.mail.disabled"><![CDATA[Die E-Mail-Benachrichtigung wurde erfolgreich abgeschaltet.]]></item>
- <item name="wcf.user.notification.mail.footer"><![CDATA[Diese E-Mail ist eine automatische Benachrichtigung. BITTE {if LANGUAGE_USE_INFORMAL_VARIANT}ANTWORTE{else}ANTWORTEN SIE{/if} NICHT AUF DIESE E-MAIL.
+
+ <!-- Emails -->
+ <item name="wcf.user.notification.mail.subject"><![CDATA[Neue Benachrichtigung: {@$title}]]></item>
+ <item name="wcf.user.notification.mail.plaintext.intro"><![CDATA[Hallo {@$mailbox->getUser()->username},]]></item>
+ <item name="wcf.user.notification.mail.plaintext.outro"><![CDATA[Diese E-Mail ist eine automatische Benachrichtigung. BITTE {if LANGUAGE_USE_INFORMAL_VARIANT}ANTWORTE{else}ANTWORTEN SIE{/if} NICHT AUF DIESE E-MAIL.
{if LANGUAGE_USE_INFORMAL_VARIANT}Du kannst{else}Sie können{/if} die Einstellungen für {if LANGUAGE_USE_INFORMAL_VARIANT}deine{else}Ihre{/if} Benachrichtigungen auf {@PAGE_TITLE|language} unter folgender URL detailliert konfigurieren:
{link controller='NotificationSettings' isEmail=true}{/link}
{if LANGUAGE_USE_INFORMAL_VARIANT}Möchtest du{else}Möchten Sie{/if} diese E-Mail-Benachrichtigung in Zukunft nicht mehr erhalten, {if LANGUAGE_USE_INFORMAL_VARIANT}kannst du{else}können Sie{/if} folgenden Link aufrufen, um die Benachrichtigung abzuschalten:
-{link controller='NotificationDisable' isEmail=true}eventID={@$notification->eventID}&userID={@$user->userID}&token={@$token}{/link}]]></item>
- <item name="wcf.user.notification.mail.header"><![CDATA[Hallo {@$user->username},]]></item>
- <item name="wcf.user.notification.mail.subject"><![CDATA[Neue Benachrichtigung: {@$title}]]></item>
+{link controller='NotificationDisable' isEmail=true}eventID={@$event->eventID}&userID={@$mailbox->getUser()->userID}&token={@$mailbox->getUser()->notificationMailToken}{/link}]]></item>
<item name="wcf.user.notification.mail.daily.subject"><![CDATA[{if $count == 1}Neue Benachrichtigung{else}{#$count} neue Benachrichtigungen{/if}]]></item>
<item name="wcf.user.notification.mail.daily.footer"><![CDATA[Diese E-Mail ist eine automatische Benachrichtigung. BITTE {if LANGUAGE_USE_INFORMAL_VARIANT}ANTWORTE{else}ANTWORTEN SIE{/if} NICHT AUF DIESE E-MAIL.
{if LANGUAGE_USE_INFORMAL_VARIANT}Möchtest du{else}Möchten Sie{/if} diese E-Mail-Benachrichtigung in Zukunft nicht mehr erhalten, {if LANGUAGE_USE_INFORMAL_VARIANT}kannst du{else}können Sie{/if} folgenden Link aufrufen, um die Benachrichtigung abzuschalten:
{link controller='NotificationDisable' isEmail=true}userID={@$user->userID}&token={@$token}{/link}]]></item>
+
<item name="wcf.user.notification.mailNotificationType.none"><![CDATA[Keine E-Mail-Benachrichtigung]]></item>
<item name="wcf.user.notification.mailNotificationType.instant"><![CDATA[Sofortige E-Mail-Benachrichtigung]]></item>
<item name="wcf.user.notification.mailNotificationType.daily"><![CDATA[Tägliche E-Mail-Benachrichtigung]]></item>