diff --git a/developer_manual/digging_deeper/email.rst b/developer_manual/digging_deeper/email.rst new file mode 100644 index 000000000..11856272f --- /dev/null +++ b/developer_manual/digging_deeper/email.rst @@ -0,0 +1,46 @@ +===== +Email +===== + +Nextcloud has a mailer component to send email from an admin-defined account. + +Basic usage +----------- + +The mailer is hidden behind the ``\OCP\Mail\IMailer`` interface that can be :ref:`injected`: + +.. code-block:: php + :caption: lib/Service/MailService.php + + mailer = $mailer; + } + + public function notify(string $email): void { + $message = $this->mailer->createMessage(); + $message->setTo([$email]); + $this->mailer->send($message); + } + } + +Inline attachments +------------------ + +Inline attachments can be appended to a message with ``IMessage::attachInline``: + +.. code-block:: php + + /** @var IMessage $message */ + $message->attachInline( + "this is a test", // Body + "test.txt", // Name + "text/plain" // Content type + ); + $this->mailer->send($message); diff --git a/developer_manual/digging_deeper/index.rst b/developer_manual/digging_deeper/index.rst index b9e415ebd..368ea6525 100644 --- a/developer_manual/digging_deeper/index.rst +++ b/developer_manual/digging_deeper/index.rst @@ -10,6 +10,7 @@ Digging deeper debugging classloader continuous_integration + email flow http_client javascript-apis