namespace wcf\form;
use wcf\data\user\UserProfile;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
+use wcf\system\email\mime\MimePartFacade;
+use wcf\system\email\mime\RecipientAwareTextMimePart;
+use wcf\system\email\Email;
+use wcf\system\email\Mailbox;
+use wcf\system\email\UserMailbox;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
-use wcf\system\mail\Mail;
use wcf\system\page\PageLocationManager;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
* recipient's user object
* @var UserProfile
*/
- public $user = 0;
+ public $user = null;
/**
* true to add the reply-to header
public function save() {
parent::save();
- // get recipient's language
- $userLanguage = $this->user->getLanguage();
-
// build message data
- $subjectData = [
- 'username' => WCF::getUser()->userID ? WCF::getUser()->username : $this->email,
- 'subject' => $this->subject
- ];
$messageData = [
'message' => $this->message,
- 'recipient' => $this->user,
'username' => WCF::getUser()->userID ? WCF::getUser()->username : $this->email
];
// build mail
- $mail = new Mail([$this->user->username => $this->user->email], $userLanguage->getDynamicVariable('wcf.user.mail.mail.subject', $subjectData), $userLanguage->getDynamicVariable('wcf.user.mail.mail', $messageData));
- $mail->setLanguage($userLanguage);
+ $email = new Email();
+ $email->addRecipient(new UserMailbox($this->user->getDecoratedObject()));
+ $email->setSubject($this->user->getLanguage()->getDynamicVariable('wcf.user.mail.mail.subject', [
+ 'username' => WCF::getUser()->userID ? WCF::getUser()->username : $this->email,
+ 'subject' => $this->subject
+ ]));
+ $email->setBody(new MimePartFacade([
+ new RecipientAwareTextMimePart('text/html', 'email_mail', 'wcf', $messageData),
+ new RecipientAwareTextMimePart('text/plain', 'email_mail', 'wcf', $messageData)
+ ]));
// add reply-to tag
if (WCF::getUser()->userID) {
- if ($this->showAddress) $mail->setHeader('Reply-To: '.Mail::buildAddress(WCF::getUser()->username, WCF::getUser()->email));
+ if ($this->showAddress) {
+ $email->setReplyTo(new UserMailbox(WCF::getUser()));
+ }
}
else {
- $mail->setHeader('Reply-To: '.$this->email);
+ $email->setReplyTo(new Mailbox($this->email));
}
// send mail
- $mail->send();
+ $email->send();
$this->saved();
// forward to profile page
<category name="wcf.user.mail">
<item name="wcf.user.mail.information"><![CDATA[Informationen]]></item>
- <item name="wcf.user.mail.mail"><![CDATA[Hallo {@$recipient->username},
+ <item name="wcf.user.mail.mail.subject"><![CDATA[Nachricht von {@$username}: {@$subject}]]></item>
+ <item name="wcf.user.mail.mail.plaintext"><![CDATA[Hallo {@$mailbox->getUser()->username},
+
+„{@$username}“ hat {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if} über die Website {@PAGE_TITLE|language} [URL:{link isEmail=true}{/link}] folgende Nachricht gesandt:
-"{@$username}" hat {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if} über die Website "{@PAGE_TITLE|language}" folgende Nachricht gesandt:
{@$message}]]></item>
- <item name="wcf.user.mail.mail.subject"><![CDATA[Nachricht von {@$username}: {@$subject}]]></item>
+ <item name="wcf.user.mail.mail.html"><![CDATA[<h1>Hallo {$mailbox->getUser()->username},</h1>
+
+<p>„{$username}“ hat {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if} über die Website <a href="{link isEmail=true}{/link}">{PAGE_TITLE|language}</a> folgende Nachricht gesandt:</p>
+
+<p>{@$message|newlineToBreak}</p>]]></item>
<item name="wcf.user.mail.message"><![CDATA[Nachricht]]></item>
<item name="wcf.user.mail.senderEmail"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Deine{else}Ihre{/if} E-Mail-Adresse]]></item>
<item name="wcf.user.mail.sent"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Deine{else}Ihre{/if} Nachricht an {$user->username} wurde erfolgreich versandt.]]></item>
<category name="wcf.user.mail">
<item name="wcf.user.mail.information"><![CDATA[Details]]></item>
- <item name="wcf.user.mail.mail"><![CDATA[Dear {@$recipient->username},
+ <item name="wcf.user.mail.mail.subject"><![CDATA[Message From {@$username}: {@$subject}]]></item>
+ <item name="wcf.user.mail.mail.plaintext"><![CDATA[Dear {@$mailbox->getUser()->username},
+
+“{@$username}” sent you a message on {@PAGE_TITLE|language} [URL:{link isEmail=true}{/link}]:
-"{@$username}" sent you a message on "{@PAGE_TITLE|language}":
{@$message}]]></item>
- <item name="wcf.user.mail.mail.subject"><![CDATA[Message From {@$username}: {@$subject}]]></item>
+<item name="wcf.user.mail.mail.html"><![CDATA[<h1>Dear {$mailbox->getUser()->username},</h1>
+
+<p>„{$username}“ sent you a message on <a href="{link isEmail=true}{/link}">{PAGE_TITLE|language}</a>:</p>
+
+<p>{@$message|newlineToBreak}</p>]]></item>
<item name="wcf.user.mail.message"><![CDATA[Message]]></item>
<item name="wcf.user.mail.senderEmail"><![CDATA[Your email address]]></item>
<item name="wcf.user.mail.sent"><![CDATA[Message has been sent to {$user->username}.]]></item>