aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Mail/Mailer.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Mail/Mailer.php')
-rw-r--r--lib/private/Mail/Mailer.php65
1 files changed, 52 insertions, 13 deletions
diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php
index e866cbfdbbc..bdc4d6760e0 100644
--- a/lib/private/Mail/Mailer.php
+++ b/lib/private/Mail/Mailer.php
@@ -27,6 +27,7 @@ use Psr\Log\LoggerInterface;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mailer\Mailer as SymfonyMailer;
use Symfony\Component\Mailer\MailerInterface;
+use Symfony\Component\Mailer\Transport\NullTransport;
use Symfony\Component\Mailer\Transport\SendmailTransport;
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
use Symfony\Component\Mailer\Transport\Smtp\Stream\SocketStream;
@@ -52,16 +53,22 @@ use Symfony\Component\Mime\Exception\RfcComplianceException;
* @package OC\Mail
*/
class Mailer implements IMailer {
+ // Do not move this block or change it's content without contacting the release crew
+ public const DEFAULT_DIMENSIONS = '252x120';
+ // Do not move this block or change it's content without contacting the release crew
+
+ public const MAX_LOGO_SIZE = 105;
+
private ?MailerInterface $instance = null;
public function __construct(
- private IConfig $config,
- private LoggerInterface $logger,
- private Defaults $defaults,
- private IURLGenerator $urlGenerator,
- private IL10N $l10n,
+ private IConfig $config,
+ private LoggerInterface $logger,
+ private Defaults $defaults,
+ private IURLGenerator $urlGenerator,
+ private IL10N $l10n,
private IEventDispatcher $dispatcher,
- private IFactory $l10nFactory,
+ private IFactory $l10nFactory,
) {
}
@@ -97,6 +104,31 @@ class Mailer implements IMailer {
* @since 12.0.0
*/
public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate {
+ $logoDimensions = $this->config->getAppValue('theming', 'logoDimensions', self::DEFAULT_DIMENSIONS);
+ if (str_contains($logoDimensions, 'x')) {
+ [$width, $height] = explode('x', $logoDimensions);
+ $width = (int)$width;
+ $height = (int)$height;
+
+ if ($width > self::MAX_LOGO_SIZE || $height > self::MAX_LOGO_SIZE) {
+ if ($width === $height) {
+ $logoWidth = self::MAX_LOGO_SIZE;
+ $logoHeight = self::MAX_LOGO_SIZE;
+ } elseif ($width > $height) {
+ $logoWidth = self::MAX_LOGO_SIZE;
+ $logoHeight = (int)(($height / $width) * self::MAX_LOGO_SIZE);
+ } else {
+ $logoWidth = (int)(($width / $height) * self::MAX_LOGO_SIZE);
+ $logoHeight = self::MAX_LOGO_SIZE;
+ }
+ } else {
+ $logoWidth = $width;
+ $logoHeight = $height;
+ }
+ } else {
+ $logoWidth = $logoHeight = null;
+ }
+
$class = $this->config->getSystemValueString('mail_template_class', '');
if ($class !== '' && class_exists($class) && is_a($class, EMailTemplate::class, true)) {
@@ -104,6 +136,8 @@ class Mailer implements IMailer {
$this->defaults,
$this->urlGenerator,
$this->l10nFactory,
+ $logoWidth,
+ $logoHeight,
$emailId,
$data
);
@@ -113,6 +147,8 @@ class Mailer implements IMailer {
$this->defaults,
$this->urlGenerator,
$this->l10nFactory,
+ $logoWidth,
+ $logoHeight,
$emailId,
$data
);
@@ -196,9 +232,6 @@ class Mailer implements IMailer {
}
/**
- * @deprecated 26.0.0 Implicit validation is done in \OC\Mail\Message::setRecipients
- * via \Symfony\Component\Mime\Address::__construct
- *
* @param string $email Email address to be validated
* @return bool True if the mail address is valid, false otherwise
*/
@@ -220,9 +253,10 @@ class Mailer implements IMailer {
return $this->instance;
}
- $transport = null;
-
switch ($this->config->getSystemValueString('mail_smtpmode', 'smtp')) {
+ case 'null':
+ $transport = new NullTransport();
+ break;
case 'sendmail':
$transport = $this->getSendMailInstance();
break;
@@ -232,7 +266,9 @@ class Mailer implements IMailer {
break;
}
- return new SymfonyMailer($transport);
+ $this->instance = new SymfonyMailer($transport);
+
+ return $this->instance;
}
/**
@@ -299,8 +335,10 @@ class Mailer implements IMailer {
break;
default:
$sendmail = \OCP\Server::get(IBinaryFinder::class)->findBinaryPath('sendmail');
- if ($sendmail === null) {
+ if ($sendmail === false) {
+ // fallback (though not sure what good it'll do)
$sendmail = '/usr/sbin/sendmail';
+ $this->logger->debug('sendmail binary search failed, using fallback ' . $sendmail, ['app' => 'core']);
}
$binaryPath = $sendmail;
break;
@@ -311,6 +349,7 @@ class Mailer implements IMailer {
default => ' -bs',
};
+ $this->logger->debug('Using sendmail binary: ' . $binaryPath, ['app' => 'core']);
return new SendmailTransport($binaryPath . $binaryParam, null, $this->logger);
}
}