feat(devmanual): Document system email subject and body methods

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst
2023-06-02 08:53:41 +02:00
parent ee1438b412
commit 425224594b
2 changed files with 9 additions and 1 deletions

View File

@@ -45,7 +45,8 @@ Back-end changes
Added APIs
^^^^^^^^^^
* tbd
* ``\OCP\Mail\IMessage::setSubject`` to set an email subject. See :ref:`email` for an example.
* ``\OCP\Mail\IMessage::setHtmlBody`` and ``\OCP\Mail\IMessage::setPlainBody`` to set an email body See :ref:`email` for an example.
Changed APIs
^^^^^^^^^^^^

View File

@@ -1,3 +1,5 @@
.. _email:
=====
Email
=====
@@ -25,6 +27,11 @@ The mailer is hidden behind the ``\OCP\Mail\IMailer`` interface that can be :ref
public function notify(string $email): void {
$message = $this->mailer->createMessage();
$message->setSubject("Hello from Nextcloud");
$message->setPlainBody("This is some text");
$message->setHtmlBody(
"<!doctype html><html><body>This is some <b>text</b></body></html>"
);
$message->setTo([$email]);
$this->mailer->send($message);
}