Merge pull request #40151 from summersab/refactor/OC-Server-getMailer

This commit is contained in:
John Molakvoæ 2024-05-30 17:50:28 +02:00 committed by GitHub
commit 94a1b8a591
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 7 additions and 5 deletions

View file

@ -38,7 +38,7 @@ use Symfony\Component\Mime\Exception\RfcComplianceException;
*
* Example usage:
*
* $mailer = \OC::$server->getMailer();
* $mailer = \OC::$server->get(\OCP\Mail\IMailer::class);
* $message = $mailer->createMessage();
* $message->setSubject('Your Subject');
* $message->setFrom(array('cloud@domain.org' => 'ownCloud Notifier'));

View file

@ -22,6 +22,7 @@ use OCP\Federation\ICloudFederationFactory;
use OCP\Files\IRootFolder;
use OCP\Http\Client\IClientService;
use OCP\IServerContainer;
use OCP\Mail\IMailer;
use OCP\Security\IHasher;
use OCP\Share\IManager;
use OCP\Share\IProviderFactory;
@ -79,7 +80,7 @@ class ProviderFactory implements IProviderFactory {
$this->serverContainer->getUserManager(),
$this->serverContainer->getGroupManager(),
$this->serverContainer->get(IRootFolder::class),
$this->serverContainer->getMailer(),
$this->serverContainer->get(IMailer::class),
$this->serverContainer->query(Defaults::class),
$this->serverContainer->getL10NFactory(),
$this->serverContainer->getURLGenerator(),
@ -172,7 +173,7 @@ class ProviderFactory implements IProviderFactory {
$this->serverContainer->get(IRootFolder::class),
$this->serverContainer->getL10N('sharebymail'),
$this->serverContainer->get(LoggerInterface::class),
$this->serverContainer->getMailer(),
$this->serverContainer->get(IMailer::class),
$this->serverContainer->getURLGenerator(),
$this->serverContainer->getActivityManager(),
$settingsManager,

View file

@ -14,7 +14,7 @@ namespace OCP\Mail;
*
* Example usage:
*
* $mailer = \OC::$server->getMailer();
* $mailer = \OC::$server->get(\OCP\Mail\IMailer::class);
* $message = $mailer->createMessage();
* $message->setSubject('Your Subject');
* $message->setFrom(['cloud@domain.org' => 'Nextcloud Notifier']);

View file

@ -13,6 +13,7 @@ namespace OCP;
use bantu\IniGetWrapper\IniGetWrapper;
use OC\AppScriptDependency;
use OC\AppScriptSort;
use OCP\Mail\IMailer;
use OCP\Share\IManager;
use Psr\Container\ContainerExceptionInterface;
use Psr\Log\LoggerInterface;
@ -302,7 +303,7 @@ class Util {
$host_name = $config->getSystemValueString('mail_domain', $host_name);
$defaultEmailAddress = $user_part.'@'.$host_name;
$mailer = \OC::$server->getMailer();
$mailer = \OC::$server->get(IMailer::class);
if ($mailer->validateMailAddress($defaultEmailAddress)) {
return $defaultEmailAddress;
}