summaryrefslogtreecommitdiffstats
path: root/apps/sharebymail/lib/ShareByMailProvider.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-10-18 15:41:18 +0200
committerGitHub <noreply@github.com>2017-10-18 15:41:18 +0200
commitbea04d12d5a9ae8653277fc6379468d990f397ea (patch)
tree8b6b34a0e4a5f822fa5e451462fe5fe67fafceb0 /apps/sharebymail/lib/ShareByMailProvider.php
parent8e884ba52fe3796d0da1e108a7a8fb1b43e6d554 (diff)
parentcc798fd65f48e4cfc4748f35859c453a6eff4e25 (diff)
downloadnextcloud-server-bea04d12d5a9ae8653277fc6379468d990f397ea.tar.gz
nextcloud-server-bea04d12d5a9ae8653277fc6379468d990f397ea.zip
Merge pull request #6515 from nextcloud/templating-of-email-subjects
Allow templating of email subjects
Diffstat (limited to 'apps/sharebymail/lib/ShareByMailProvider.php')
-rw-r--r--apps/sharebymail/lib/ShareByMailProvider.php20
1 files changed, 7 insertions, 13 deletions
diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php
index 516e4e243bf..f610a1a5fa9 100644
--- a/apps/sharebymail/lib/ShareByMailProvider.php
+++ b/apps/sharebymail/lib/ShareByMailProvider.php
@@ -380,8 +380,6 @@ class ShareByMailProvider implements IShareProvider {
\DateTime $expiration = null) {
$initiatorUser = $this->userManager->get($initiator);
$initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator;
- $subject = (string)$this->l->t('%s shared »%s« with you', array($initiatorDisplayName, $filename));
-
$message = $this->mailer->createMessage();
$emailTemplate = $this->mailer->createEMailTemplate('sharebymail.RecipientNotification', [
@@ -392,6 +390,7 @@ class ShareByMailProvider implements IShareProvider {
'shareWith' => $shareWith,
]);
+ $emailTemplate->setSubject($this->l->t('%s shared »%s« with you', array($initiatorDisplayName, $filename)));
$emailTemplate->addHeader();
$emailTemplate->addHeading($this->l->t('%s shared »%s« with you', [$initiatorDisplayName, $filename]), false);
$text = $this->l->t('%s shared »%s« with you.', [$initiatorDisplayName, $filename]);
@@ -428,9 +427,7 @@ class ShareByMailProvider implements IShareProvider {
$emailTemplate->addFooter();
}
- $message->setSubject($subject);
- $message->setPlainBody($emailTemplate->renderText());
- $message->setHtmlBody($emailTemplate->renderHtml());
+ $message->useTemplate($emailTemplate);
$this->mailer->send($message);
}
@@ -455,7 +452,6 @@ class ShareByMailProvider implements IShareProvider {
$initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator;
$initiatorEmailAddress = ($initiatorUser instanceof IUser) ? $initiatorUser->getEMailAddress() : null;
- $subject = (string)$this->l->t('Password to access »%s« shared to you by %s', [$filename, $initiatorDisplayName]);
$plainBodyPart = $this->l->t("%s shared »%s« with you.\nYou should have already received a separate mail with a link to access it.\n", [$initiatorDisplayName, $filename]);
$htmlBodyPart = $this->l->t('%s shared »%s« with you. You should have already received a separate mail with a link to access it.', [$initiatorDisplayName, $filename]);
@@ -468,6 +464,8 @@ class ShareByMailProvider implements IShareProvider {
'initiatorEmail' => $initiatorEmailAddress,
'shareWith' => $shareWith,
]);
+
+ $emailTemplate->setSubject($this->l->t('Password to access »%s« shared to you by %s', [$filename, $initiatorDisplayName]));
$emailTemplate->addHeader();
$emailTemplate->addHeading($this->l->t('Password to access »%s«', [$filename]), false);
$emailTemplate->addBodyText($htmlBodyPart, $plainBodyPart);
@@ -491,9 +489,7 @@ class ShareByMailProvider implements IShareProvider {
}
$message->setTo([$shareWith]);
- $message->setSubject($subject);
- $message->setBody($emailTemplate->renderText(), 'text/plain');
- $message->setHtmlBody($emailTemplate->renderHtml());
+ $message->useTemplate($emailTemplate);
$this->mailer->send($message);
$this->createPasswordSendActivity($share, $shareWith, false);
@@ -524,7 +520,6 @@ class ShareByMailProvider implements IShareProvider {
);
}
- $subject = (string)$this->l->t('Password to access »%s« shared with %s', [$filename, $shareWith]);
$bodyPart = $this->l->t("You just shared »%s« with %s. The share was already send to the recipient. Due to the security policies defined by the administrator of %s each share needs to be protected by password and it is not allowed to send the password directly to the recipient. Therefore you need to forward the password manually to the recipient.", [$filename, $shareWith, $this->defaults->getName()]);
$message = $this->mailer->createMessage();
@@ -536,6 +531,7 @@ class ShareByMailProvider implements IShareProvider {
'shareWith' => $shareWith,
]);
+ $emailTemplate->setSubject($this->l->t('Password to access »%s« shared with %s', [$filename, $shareWith]));
$emailTemplate->addHeader();
$emailTemplate->addHeading($this->l->t('Password to access »%s«', [$filename]), false);
$emailTemplate->addBodyText($bodyPart);
@@ -547,9 +543,7 @@ class ShareByMailProvider implements IShareProvider {
$message->setFrom([$initiatorEMailAddress => $initiatorDisplayName]);
}
$message->setTo([$initiatorEMailAddress => $initiatorDisplayName]);
- $message->setSubject($subject);
- $message->setBody($emailTemplate->renderText(), 'text/plain');
- $message->setHtmlBody($emailTemplate->renderHtml());
+ $message->useTemplate($emailTemplate);
$this->mailer->send($message);
$this->createPasswordSendActivity($share, $shareWith, true);