Mail.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\Settings\Settings\Admin;
  7. use OCP\AppFramework\Http\TemplateResponse;
  8. use OCP\IConfig;
  9. use OCP\IL10N;
  10. use OCP\Settings\IDelegatedSettings;
  11. class Mail implements IDelegatedSettings {
  12. /** @var IConfig */
  13. private $config;
  14. /** @var IL10N $l */
  15. private $l;
  16. /**
  17. * @param IConfig $config
  18. * @param IL10N $l
  19. */
  20. public function __construct(IConfig $config, IL10N $l) {
  21. $this->config = $config;
  22. $this->l = $l;
  23. }
  24. /**
  25. * @return TemplateResponse
  26. */
  27. public function getForm() {
  28. $parameters = [
  29. // Mail
  30. 'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
  31. 'mail_domain' => $this->config->getSystemValue('mail_domain', ''),
  32. 'mail_from_address' => $this->config->getSystemValue('mail_from_address', ''),
  33. 'mail_smtpmode' => $this->config->getSystemValue('mail_smtpmode', ''),
  34. 'mail_smtpsecure' => $this->config->getSystemValue('mail_smtpsecure', ''),
  35. 'mail_smtphost' => $this->config->getSystemValue('mail_smtphost', ''),
  36. 'mail_smtpport' => $this->config->getSystemValue('mail_smtpport', ''),
  37. 'mail_smtpauth' => $this->config->getSystemValue('mail_smtpauth', false),
  38. 'mail_smtpname' => $this->config->getSystemValue('mail_smtpname', ''),
  39. 'mail_smtppassword' => $this->config->getSystemValue('mail_smtppassword', ''),
  40. 'mail_sendmailmode' => $this->config->getSystemValue('mail_sendmailmode', 'smtp'),
  41. ];
  42. if ($parameters['mail_smtppassword'] !== '') {
  43. $parameters['mail_smtppassword'] = '********';
  44. }
  45. if ($parameters['mail_smtpmode'] === '' || $parameters['mail_smtpmode'] === 'php') {
  46. $parameters['mail_smtpmode'] = 'smtp';
  47. }
  48. return new TemplateResponse('settings', 'settings/admin/additional-mail', $parameters, '');
  49. }
  50. /**
  51. * @return string the section ID, e.g. 'sharing'
  52. */
  53. public function getSection() {
  54. return 'server';
  55. }
  56. /**
  57. * @return int whether the form should be rather on the top or bottom of
  58. * the admin section. The forms are arranged in ascending order of the
  59. * priority values. It is required to return a value between 0 and 100.
  60. *
  61. * E.g.: 70
  62. */
  63. public function getPriority() {
  64. return 10;
  65. }
  66. public function getName(): ?string {
  67. return $this->l->t('Email server');
  68. }
  69. public function getAuthorizedAppConfig(): array {
  70. return [];
  71. }
  72. }