1
0

additional-mail.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. /** @var \OCP\IL10N $l */
  24. /** @var array $_ */
  25. $mail_smtpauthtype = [
  26. '' => $l->t('None'),
  27. 'LOGIN' => $l->t('Login'),
  28. 'PLAIN' => $l->t('Plain'),
  29. 'NTLM' => $l->t('NT LAN Manager'),
  30. ];
  31. $mail_smtpsecure = [
  32. '' => $l->t('None'),
  33. 'ssl' => $l->t('SSL/TLS'),
  34. 'tls' => $l->t('STARTTLS'),
  35. ];
  36. $mail_smtpmode = [
  37. ['php', 'PHP'],
  38. ['smtp', 'SMTP'],
  39. ];
  40. if ($_['sendmail_is_available']) {
  41. $mail_smtpmode[] = ['sendmail', 'Sendmail'];
  42. }
  43. if ($_['mail_smtpmode'] === 'qmail') {
  44. $mail_smtpmode[] = ['qmail', 'qmail'];
  45. }
  46. ?>
  47. <div class="section" id="mail_general_settings">
  48. <form id="mail_general_settings_form" class="mail_settings">
  49. <h2><?php p($l->t('Email server'));?></h2>
  50. <a target="_blank" rel="noreferrer" class="icon-info"
  51. title="<?php p($l->t('Open documentation'));?>"
  52. href="<?php p(link_to_docs('admin-email')); ?>"></a>
  53. <p class="settings-hint"><?php p($l->t('It is important to set up this server to be able to send emails, like for password reset and notifications.')); ?></p>
  54. <p><span id="mail_settings_msg" class="msg"></span></p>
  55. <p>
  56. <label for="mail_smtpmode"><?php p($l->t('Send mode')); ?></label>
  57. <select name="mail_smtpmode" id="mail_smtpmode">
  58. <?php foreach ($mail_smtpmode as $smtpmode):
  59. $selected = '';
  60. if ($smtpmode[0] == $_['mail_smtpmode']):
  61. $selected = 'selected="selected"';
  62. endif; ?>
  63. <option value="<?php p($smtpmode[0])?>" <?php p($selected) ?>><?php p($smtpmode[1]) ?></option>
  64. <?php endforeach;?>
  65. </select>
  66. <label id="mail_smtpsecure_label" for="mail_smtpsecure"
  67. <?php if ($_['mail_smtpmode'] !== 'smtp') print_unescaped(' class="hidden"'); ?>>
  68. <?php p($l->t('Encryption')); ?>
  69. </label>
  70. <select name="mail_smtpsecure" id="mail_smtpsecure"
  71. <?php if ($_['mail_smtpmode'] !== 'smtp') print_unescaped(' class="hidden"'); ?>>
  72. <?php foreach ($mail_smtpsecure as $secure => $name):
  73. $selected = '';
  74. if ($secure == $_['mail_smtpsecure']):
  75. $selected = 'selected="selected"';
  76. endif; ?>
  77. <option value="<?php p($secure)?>" <?php p($selected) ?>><?php p($name) ?></option>
  78. <?php endforeach;?>
  79. </select>
  80. </p>
  81. <p>
  82. <label for="mail_from_address"><?php p($l->t('From address')); ?></label>
  83. <input type="text" name="mail_from_address" id="mail_from_address" placeholder="<?php p($l->t('mail'))?>"
  84. value="<?php p($_['mail_from_address']) ?>" />@
  85. <input type="text" name="mail_domain" id="mail_domain" placeholder="example.com"
  86. value="<?php p($_['mail_domain']) ?>" />
  87. </p>
  88. <p id="setting_smtpauth" <?php if ($_['mail_smtpmode'] !== 'smtp') print_unescaped(' class="hidden"'); ?>>
  89. <label for="mail_smtpauthtype"><?php p($l->t('Authentication method')); ?></label>
  90. <select name="mail_smtpauthtype" id="mail_smtpauthtype">
  91. <?php foreach ($mail_smtpauthtype as $authtype => $name):
  92. $selected = '';
  93. if ($authtype == $_['mail_smtpauthtype']):
  94. $selected = 'selected="selected"';
  95. endif; ?>
  96. <option value="<?php p($authtype)?>" <?php p($selected) ?>><?php p($name) ?></option>
  97. <?php endforeach;?>
  98. </select>
  99. <input type="checkbox" name="mail_smtpauth" id="mail_smtpauth" class="checkbox" value="1"
  100. <?php if ($_['mail_smtpauth']) print_unescaped('checked="checked"'); ?> />
  101. <label for="mail_smtpauth"><?php p($l->t('Authentication required')); ?></label>
  102. </p>
  103. <p id="setting_smtphost" <?php if ($_['mail_smtpmode'] !== 'smtp') print_unescaped(' class="hidden"'); ?>>
  104. <label for="mail_smtphost"><?php p($l->t('Server address')); ?></label>
  105. <input type="text" name="mail_smtphost" id="mail_smtphost" placeholder="smtp.example.com"
  106. value="<?php p($_['mail_smtphost']) ?>" />
  107. :
  108. <input type="text" name="mail_smtpport" id="mail_smtpport" placeholder="<?php p($l->t('Port'))?>"
  109. value="<?php p($_['mail_smtpport']) ?>" />
  110. </p>
  111. </form>
  112. <form class="mail_settings" id="mail_credentials_settings">
  113. <p id="mail_credentials" <?php if (!$_['mail_smtpauth'] || $_['mail_smtpmode'] !== 'smtp') print_unescaped(' class="hidden"'); ?>>
  114. <label for="mail_smtpname"><?php p($l->t('Credentials')); ?></label>
  115. <input type="text" name="mail_smtpname" id="mail_smtpname" placeholder="<?php p($l->t('SMTP Username'))?>"
  116. value="<?php p($_['mail_smtpname']) ?>" />
  117. <input type="text" name="mail_smtppassword" id="mail_smtppassword" autocomplete="off"
  118. placeholder="<?php p($l->t('SMTP Password'))?>" value="<?php p($_['mail_smtppassword']) ?>" />
  119. <input id="mail_credentials_settings_submit" type="button" value="<?php p($l->t('Store credentials')) ?>">
  120. </p>
  121. </form>
  122. <br />
  123. <em><?php p($l->t('Test email settings')); ?></em>
  124. <input type="submit" name="sendtestemail" id="sendtestemail" value="<?php p($l->t('Send email')); ?>"/>
  125. <span id="sendtestmail_msg" class="msg"></span>
  126. </div>