You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Mail.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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_smtpauth' => $this->config->getSystemValue('mail_smtpauth', false),
  60. 'mail_smtpname' => $this->config->getSystemValue('mail_smtpname', ''),
  61. 'mail_smtppassword' => $this->config->getSystemValue('mail_smtppassword', ''),
  62. 'mail_sendmailmode' => $this->config->getSystemValue('mail_sendmailmode', 'smtp'),
  63. ];
  64. if ($parameters['mail_smtppassword'] !== '') {
  65. $parameters['mail_smtppassword'] = '********';
  66. }
  67. if ($parameters['mail_smtpmode'] === '' || $parameters['mail_smtpmode'] === 'php') {
  68. $parameters['mail_smtpmode'] = 'smtp';
  69. }
  70. return new TemplateResponse('settings', 'settings/admin/additional-mail', $parameters, '');
  71. }
  72. /**
  73. * @return string the section ID, e.g. 'sharing'
  74. */
  75. public function getSection() {
  76. return 'server';
  77. }
  78. /**
  79. * @return int whether the form should be rather on the top or bottom of
  80. * the admin section. The forms are arranged in ascending order of the
  81. * priority values. It is required to return a value between 0 and 100.
  82. *
  83. * E.g.: 70
  84. */
  85. public function getPriority() {
  86. return 10;
  87. }
  88. public function getName(): ?string {
  89. return $this->l->t('Email server');
  90. }
  91. public function getAuthorizedAppConfig(): array {
  92. return [];
  93. }
  94. }