Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-05-18 18:42:33 +0300
committerRoeland Jago Douma <rullzer@owncloud.com>2016-05-18 18:42:33 +0300
commitbabdf8477dc8498a660082ade07497d5fc3c8548 (patch)
tree6bb9f693dc653f1ba1eea86ead0df9225692ee8e /lib/public/Mail
parent4a94203492e3b475ee26b65d5992796152c645bd (diff)
Move \OCP\Mail to PSR-4
Diffstat (limited to 'lib/public/Mail')
-rw-r--r--lib/public/Mail/IMailer.php76
1 files changed, 76 insertions, 0 deletions
diff --git a/lib/public/Mail/IMailer.php b/lib/public/Mail/IMailer.php
new file mode 100644
index 00000000000..e3c751277ac
--- /dev/null
+++ b/lib/public/Mail/IMailer.php
@@ -0,0 +1,76 @@
+<?php
+/**
+ * @author Lukas Reschke <lukas@owncloud.com>
+ * @author Morris Jobke <hey@morrisjobke.de>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCP\Mail;
+use OC\Mail\Message;
+
+/**
+ * Class IMailer provides some basic functions to create a mail message that can be used in combination with
+ * \OC\Mail\Message.
+ *
+ * Example usage:
+ *
+ * $mailer = \OC::$server->getMailer();
+ * $message = $mailer->createMessage();
+ * $message->setSubject('Your Subject');
+ * $message->setFrom(['cloud@domain.org' => 'ownCloud Notifier']);
+ * $message->setTo(['recipient@domain.org' => 'Recipient']);
+ * $message->setPlainBody('The message text');
+ * $message->setHtmlBody('The <strong>message</strong> text');
+ * $mailer->send($message);
+ *
+ * This message can then be passed to send() of \OC\Mail\Mailer
+ *
+ * @package OCP\Mail
+ * @since 8.1.0
+ */
+interface IMailer {
+ /**
+ * Creates a new message object that can be passed to send()
+ *
+ * @return Message
+ * @since 8.1.0
+ */
+ public function createMessage();
+
+ /**
+ * Send the specified message. Also sets the from address to the value defined in config.php
+ * if no-one has been passed.
+ *
+ * @param Message $message Message to send
+ * @return string[] Array with failed recipients. Be aware that this depends on the used mail backend and
+ * therefore should be considered
+ * @throws \Exception In case it was not possible to send the message. (for example if an invalid mail address
+ * has been supplied.)
+ * @since 8.1.0
+ */
+ public function send(Message $message);
+
+ /**
+ * Checks if an e-mail address is valid
+ *
+ * @param string $email Email address to be validated
+ * @return bool True if the mail address is valid, false otherwise
+ * @since 8.1.0
+ */
+ public function validateMailAddress($email);
+}