Mail.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Julius Härtl <jus@bitgrid.net>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. *
  12. * @license GNU AGPL version 3 or any later version
  13. *
  14. * This program is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License as
  16. * published by the Free Software Foundation, either version 3 of the
  17. * License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. *
  27. */
  28. namespace OCA\Settings\Settings\Admin;
  29. use OCP\AppFramework\Http\TemplateResponse;
  30. use OCP\IConfig;
  31. use OCP\IL10N;
  32. use OCP\Settings\IDelegatedSettings;
  33. class Mail implements IDelegatedSettings {
  34. /** @var IConfig */
  35. private $config;
  36. /** @var IL10N $l */
  37. private $l;
  38. /**
  39. * @param IConfig $config
  40. * @param IL10N $l
  41. */
  42. public function __construct(IConfig $config, IL10N $l) {
  43. $this->config = $config;
  44. $this->l = $l;
  45. }
  46. /**
  47. * @return TemplateResponse
  48. */
  49. public function getForm() {
  50. $parameters = [
  51. // Mail
  52. 'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
  53. 'mail_domain' => $this->config->getSystemValue('mail_domain', ''),
  54. 'mail_from_address' => $this->config->getSystemValue('mail_from_address', ''),
  55. 'mail_smtpmode' => $this->config->getSystemValue('mail_smtpmode', ''),
  56. 'mail_smtpsecure' => $this->config->getSystemValue('mail_smtpsecure', ''),
  57. 'mail_smtphost' => $this->config->getSystemValue('mail_smtphost', ''),
  58. 'mail_smtpport' => $this->config->getSystemValue('mail_smtpport', ''),
  59. 'mail_smtpauthtype' => $this->config->getSystemValue('mail_smtpauthtype', ''),
  60. 'mail_smtpauth' => $this->config->getSystemValue('mail_smtpauth', false),
  61. 'mail_smtpname' => $this->config->getSystemValue('mail_smtpname', ''),
  62. 'mail_smtppassword' => $this->config->getSystemValue('mail_smtppassword', ''),
  63. 'mail_sendmailmode' => $this->config->getSystemValue('mail_sendmailmode', 'smtp'),
  64. ];
  65. if ($parameters['mail_smtppassword'] !== '') {
  66. $parameters['mail_smtppassword'] = '********';
  67. }
  68. if ($parameters['mail_smtpmode'] === '' || $parameters['mail_smtpmode'] === 'php') {
  69. $parameters['mail_smtpmode'] = 'smtp';
  70. }
  71. return new TemplateResponse('settings', 'settings/admin/additional-mail', $parameters, '');
  72. }
  73. /**
  74. * @return string the section ID, e.g. 'sharing'
  75. */
  76. public function getSection() {
  77. return 'server';
  78. }
  79. /**
  80. * @return int whether the form should be rather on the top or bottom of
  81. * the admin section. The forms are arranged in ascending order of the
  82. * priority values. It is required to return a value between 0 and 100.
  83. *
  84. * E.g.: 70
  85. */
  86. public function getPriority() {
  87. return 10;
  88. }
  89. public function getName(): ?string {
  90. return $this->l->t('Email server');
  91. }
  92. public function getAuthorizedAppConfig(): array {
  93. return [];
  94. }
  95. }