2015-02-12 12:53:27 +00:00
|
|
|
<?php
|
2019-12-03 18:57:53 +00:00
|
|
|
|
2018-03-01 20:15:39 +00:00
|
|
|
declare(strict_types=1);
|
2019-12-03 18:57:53 +00:00
|
|
|
|
2015-02-12 12:53:27 +00:00
|
|
|
/**
|
2016-07-21 15:07:57 +00:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2016-05-26 17:56:05 +00:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2015-06-25 09:43:55 +00:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2019-12-03 18:57:53 +00:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2015-03-26 10:44:34 +00:00
|
|
|
*
|
|
|
|
* @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,
|
2019-12-03 18:57:53 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-03-26 10:44:34 +00:00
|
|
|
*
|
2015-02-12 12:53:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCP\Mail;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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');
|
2017-09-15 08:55:27 +00:00
|
|
|
* $message->setFrom(['cloud@domain.org' => 'Nextcloud Notifier']);
|
2016-04-25 14:03:20 +00:00
|
|
|
* $message->setTo(['recipient@domain.org' => 'Recipient']);
|
|
|
|
* $message->setPlainBody('The message text');
|
|
|
|
* $message->setHtmlBody('The <strong>message</strong> text');
|
2015-02-12 12:53:27 +00:00
|
|
|
* $mailer->send($message);
|
|
|
|
*
|
|
|
|
* This message can then be passed to send() of \OC\Mail\Mailer
|
|
|
|
*
|
|
|
|
* @package OCP\Mail
|
2015-04-16 15:00:08 +00:00
|
|
|
* @since 8.1.0
|
2015-02-12 12:53:27 +00:00
|
|
|
*/
|
|
|
|
interface IMailer {
|
|
|
|
/**
|
|
|
|
* Creates a new message object that can be passed to send()
|
|
|
|
*
|
2017-09-15 08:55:27 +00:00
|
|
|
* @return IMessage
|
2015-04-16 15:00:08 +00:00
|
|
|
* @since 8.1.0
|
2015-02-12 12:53:27 +00:00
|
|
|
*/
|
2018-03-01 20:15:39 +00:00
|
|
|
public function createMessage(): IMessage;
|
2015-02-12 12:53:27 +00:00
|
|
|
|
2017-10-25 07:26:57 +00:00
|
|
|
/**
|
|
|
|
* @param string|null $data
|
|
|
|
* @param string|null $filename
|
|
|
|
* @param string|null $contentType
|
|
|
|
* @return IAttachment
|
|
|
|
* @since 13.0.0
|
|
|
|
*/
|
2018-03-01 20:15:39 +00:00
|
|
|
public function createAttachment($data = null, $filename = null, $contentType = null): IAttachment;
|
2017-10-25 07:26:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $path
|
|
|
|
* @param string|null $contentType
|
|
|
|
* @return IAttachment
|
|
|
|
* @since 13.0.0
|
|
|
|
*/
|
2018-03-01 20:15:39 +00:00
|
|
|
public function createAttachmentFromPath(string $path, $contentType = null): IAttachment;
|
2017-10-25 07:26:57 +00:00
|
|
|
|
2017-04-11 14:35:46 +00:00
|
|
|
/**
|
|
|
|
* Creates a new email template object
|
|
|
|
*
|
2017-09-04 13:07:19 +00:00
|
|
|
* @param string $emailId
|
|
|
|
* @param array $data
|
2017-04-11 14:35:46 +00:00
|
|
|
* @return IEMailTemplate
|
2017-09-04 13:07:19 +00:00
|
|
|
* @since 12.0.0 Parameters added in 12.0.3
|
2017-04-11 14:35:46 +00:00
|
|
|
*/
|
2018-03-01 20:15:39 +00:00
|
|
|
public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate;
|
2017-04-11 14:35:46 +00:00
|
|
|
|
2015-02-12 12:53:27 +00:00
|
|
|
/**
|
|
|
|
* Send the specified message. Also sets the from address to the value defined in config.php
|
|
|
|
* if no-one has been passed.
|
|
|
|
*
|
2017-09-15 08:55:27 +00:00
|
|
|
* @param IMessage $message Message to send
|
2015-02-12 12:53:27 +00:00
|
|
|
* @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.)
|
2015-04-16 15:00:08 +00:00
|
|
|
* @since 8.1.0
|
2015-02-12 12:53:27 +00:00
|
|
|
*/
|
2018-03-01 20:15:39 +00:00
|
|
|
public function send(IMessage $message): array;
|
2015-02-19 17:55:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
2015-04-16 15:00:08 +00:00
|
|
|
* @since 8.1.0
|
2015-02-19 17:55:27 +00:00
|
|
|
*/
|
2018-03-01 20:15:39 +00:00
|
|
|
public function validateMailAddress(string $email): bool;
|
2015-02-12 12:53:27 +00:00
|
|
|
}
|