1<?php 2 3use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel; 4use Fisharebest\Webtrees\Http\RequestHandlers\EmailPreferencesAction; 5use Fisharebest\Webtrees\I18N; 6use Fisharebest\Webtrees\View; 7 8/** 9 * @var string $DKIM_DOMAIN 10 * @var string $DKIM_KEY 11 * @var string $DKIM_SELECTOR 12 * @var string $SMTP_ACTIVE 13 * @var string $SMTP_AUTH 14 * @var string $SMTP_AUTH_USER 15 * @var string $SMTP_FROM_NAME 16 * @var string $SMTP_HELO 17 * @var string $SMTP_HOST 18 * @var string $SMTP_PORT 19 * @var string $SMTP_SSL 20 * @var string[] $mail_ssl_options 21 * @var string[] $mail_transport_options 22 * @var bool $smtp_helo_valid 23 * @var bool $smtp_from_name_valid 24 * @var string $title 25 */ 26?> 27 28<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?> 29 30<h1><?= $title ?></h1> 31 32<div class="alert alert-info"> 33 <a class="alert-link" data-toggle="collapse" href="#gmail-instructions" role="button" aria-expanded="false" aria-controls="gmail-instructions"> 34 <?= I18N::translate('Instructions for Google mail') ?> 35 </a> 36 37 <dl class="collapse" id="gmail-instructions"> 38 <dt><?= I18N::translate('Server name') ?></dt> 39 <dd>smtp.gmail.com</dd> 40 <dt><?= I18N::translate('Port number') ?></dt> 41 <dd>587</dd> 42 <dt><?= I18N::translate('Secure connection') ?></dt> 43 <dd><?= I18N::translate('tls') ?></dd> 44 <dt><?= I18N::translate('Username') ?></dt> 45 <dd>xxxxx@gmail.com</dd> 46 <dt><?= I18N::translate('Password') ?></dt> 47 <dd> 48 <?= I18N::translate('If you use two-factor authentication, create an <a href="https://myaccount.google.com/apppasswords">app password</a>.') ?> 49 <br> 50 <?= I18N::translate('If you do not use two-factor authentication, enable <a href="https://www.google.com/settings/security/lesssecureapps">less secure applications</a> and use your Google password.') ?> 51 </dd> 52 </dl> 53</div> 54 55<form method="post" action="<?= e(route(EmailPreferencesAction::class)) ?>" class="form-horizontal"> 56 <?= csrf_field() ?> 57 58 <div class="row form-group"> 59 <label for="SMTP_ACTIVE" class="col-sm-3 col-form-label"> 60 <?= /* I18N: A configuration setting */ 61 I18N::translate('Messages') ?> 62 </label> 63 <div class="col-sm-9"> 64 <?= view('components/select', ['name' => 'SMTP_ACTIVE', 'selected' => $SMTP_ACTIVE, 'options' => $mail_transport_options]) ?> 65 <p class="small text-muted"> 66 <?= /* I18N: Help text for the “Messages” site configuration setting */ 67 I18N::translate('webtrees needs to send emails, such as password reminders and website notifications.') ?> 68 </p> 69 </div> 70 </div> 71 72 <div class="row form-group"> 73 <label for="SMTP_FROM_NAME" class="col-sm-3 col-form-label"> 74 <?= /* I18N: A configuration setting */ 75 I18N::translate('Sender name') ?> 76 </label> 77 <div class="col-sm-9"> 78 <input type="email" class="form-control" id="SMTP_FROM_NAME" name="SMTP_FROM_NAME" value="<?= e($SMTP_FROM_NAME) ?>" maxlength="255"> 79 <p class="small text-muted"> 80 <?= /* I18N: Help text for the “Sender name” site configuration setting */ 81 I18N::translate('This name is used in the “From” field, when sending automatic emails from this server.') ?> 82 </p> 83 84 <?php if (!$smtp_from_name_valid) : ?> 85 <p class="alert alert-warning"> 86 <?= I18N::translate('Most mail servers require a valid email address.') ?> 87 </p> 88 <?php endif ?> 89 </div> 90 </div> 91 92 <h2><?= I18N::translate('SMTP mail server') ?></h2> 93 94 <div class="row form-group"> 95 <label for="SMTP_HOST" class="col-sm-3 col-form-label"> 96 <?= /* I18N: A configuration setting */ 97 I18N::translate('Server name') ?> 98 </label> 99 <div class="col-sm-9"> 100 <input type="text" class="form-control" id="SMTP_HOST" name="SMTP_HOST" value="<?= e($SMTP_HOST) ?>" placeholder="smtp.example.com" maxlength="255" pattern="[a-z0-9-]+(\.[a-z0-9-]+)*"> 101 <p class="small text-muted"> 102 <?= /* I18N: Help text for the “Server name” site configuration setting */ 103 I18N::translate('This is the name of the SMTP server. “localhost” means that the mail service is running on the same computer as your web server.') ?> 104 </p> 105 </div> 106 </div> 107 108 <div class="row form-group"> 109 <label for="SMTP_PORT" class="col-sm-3 col-form-label"> 110 <?= /* I18N: A configuration setting */ 111 I18N::translate('Port number') ?> 112 </label> 113 <div class="col-sm-9"> 114 <input type="text" class="form-control" id="SMTP_PORT" name="SMTP_PORT" value="<?= e($SMTP_PORT) ?>" pattern="[0-9]*" placeholder="25" maxlength="5"> 115 <p class="small text-muted"> 116 <?= /* I18N: Help text for the "Port number" site configuration setting */ 117 I18N::translate('By default, SMTP works on port 25.') ?> 118 </p> 119 </div> 120 </div> 121 122 <fieldset class="form-group"> 123 <div class="row"> 124 <legend class="col-form-label col-sm-3"> 125 <?= /* I18N: A configuration setting */ 126 I18N::translate('Use password') ?> 127 </legend> 128 <div class="col-sm-9"> 129 <?= view('components/radios-inline', ['name' => 'SMTP_AUTH', 'options' => [I18N::translate('no'), I18N::translate('yes')], 'selected' => (int) $SMTP_AUTH]) ?> 130 <p class="small text-muted"> 131 <?= /* I18N: Help text for the “Use password” site configuration setting */ 132 I18N::translate('Most SMTP servers require a password.') ?> 133 </p> 134 </div> 135 </div> 136 </fieldset> 137 138 <div class="row form-group"> 139 <label for="SMTP_AUTH_USER" class="col-sm-3 col-form-label"> 140 <?= /* I18N: A configuration setting */ 141 I18N::translate('Username') ?> 142 </label> 143 <div class="col-sm-9"> 144 <input type="text" class="form-control" id="SMTP_AUTH_USER" name="SMTP_AUTH_USER" value="<?= e($SMTP_AUTH_USER) ?>" maxlength="255"> 145 <p class="small text-muted"> 146 <?= /* I18N: Help text for the "Username" site configuration setting */ 147 I18N::translate('The username required for authentication with the SMTP server.') ?> 148 </p> 149 </div> 150 </div> 151 152 <div class="row form-group"> 153 <label for="SMTP_AUTH_PASS" class="col-sm-3 col-form-label"> 154 <?= /* I18N: A configuration setting */ 155 I18N::translate('Password') ?> 156 </label> 157 <div class="col-sm-9"> 158 <input type="password" class="form-control" id="SMTP_AUTH_PASS" name="SMTP_AUTH_PASS" value="" autocomplete="off"> 159 <p class="small text-muted"> 160 <?= /* I18N: Help text for the "Password" site configuration setting */ 161 I18N::translate('The password required for authentication with the SMTP server.') ?> 162 </p> 163 </div> 164 </div> 165 166 <div class="row form-group"> 167 <label for="SMTP_SSL" class="col-sm-3 col-form-label"> 168 <?= /* I18N: A configuration setting */ 169 I18N::translate('Secure connection') ?> 170 </label> 171 <div class="col-sm-9"> 172 <?= view('components/select', ['name' => 'SMTP_SSL', 'selected' => $SMTP_SSL, 'options' => $mail_ssl_options]) ?> 173 <p class="small text-muted"> 174 <?= /* I18N: Help text for the “Secure connection” site configuration setting */ 175 I18N::translate('Most servers do not use secure connections.') ?> 176 </p> 177 </div> 178 </div> 179 180 <div class="row form-group"> 181 <label for="SMTP_HELO" class="col-sm-3 col-form-label"> 182 <?= /* I18N: A configuration setting */ 183 I18N::translate('Sending server name') ?> 184 </label> 185 <div class="col-sm-9"> 186 <input type="text" class="form-control" id="SMTP_HELO" name="SMTP_HELO" value="<?= e($SMTP_HELO) ?>" maxlength="255" pattern="[a-z0-9-]+(\.[a-z0-9-]+)*"> 187 <p class="small text-muted"> 188 <?= /* I18N: Help text for the "Sending server name" site configuration setting */ 189 I18N::translate('Most mail servers require that the sending server identifies itself correctly, using a valid domain name.') ?> 190 </p> 191 192 <?php if (!$smtp_helo_valid) : ?> 193 <p class="alert alert-warning"> 194 <?= I18N::translate('Most mail servers require a valid domain name.') ?> 195 </p> 196 <?php endif ?> 197 </div> 198 </div> 199 200 <h2> 201 <?= /* I18N: https://en.wikipedia.org/wiki/DomainKeys_Identified_Mail */ 202 I18N::translate('DKIM digital signature') ?> 203 </h2> 204 205 <div class="row form-group"> 206 <label for="DKIM_DOMAIN" class="col-sm-3 col-form-label"> 207 <?= I18N::translate('Domain name') ?> 208 </label> 209 <div class="col-sm-9"> 210 <input type="text" class="form-control" id="DKIM_DOMAIN" name="DKIM_DOMAIN" value="<?= e($DKIM_DOMAIN) ?>" maxlength="255"> 211 </div> 212 </div> 213 214 <div class="row form-group"> 215 <label for="DKIM_SELECTOR" class="col-sm-3 col-form-label"> 216 <?= I18N::translate('Selector') ?> 217 </label> 218 <div class="col-sm-9"> 219 <input type="text" class="form-control" id="DKIM_SELECTOR" name="DKIM_SELECTOR" value="<?= e($DKIM_SELECTOR) ?>" maxlength="255"> 220 </div> 221 </div> 222 223 <div class="row form-group"> 224 <label for="DKIM_KEY" class="col-sm-3 col-form-label"> 225 <?= I18N::translate('Private key') ?> 226 </label> 227 <div class="col-sm-9"> 228 <textarea class="form-control" id="DKIM_KEY" name="DKIM_KEY"><?= e($DKIM_KEY) ?></textarea> 229 </div> 230 </div> 231 232 <hr> 233 234 <div class="row form-group"> 235 <div class="offset-sm-3 col-sm-9"> 236 <p class="form-check"> 237 <input class="form-check-input" type="checkbox" id="test" name="test"> 238 <label class="form-check-label" for="test"> 239 <?= I18N::translate('Send a test email using these settings') ?> 240 </label> 241 </p> 242 243 <button type="submit" class="btn btn-primary"> 244 <?= view('icons/save') ?> 245 <?= I18N::translate('save') ?> 246 </button> 247 248 <a href="<?= e(route(ControlPanel::class)) ?>" class="btn btn-secondary"> 249 <?= view('icons/cancel') ?> 250 <?= I18N::translate('cancel') ?> 251 </a> 252 </div> 253 </div> 254</form> 255 256<?php View::push('javascript') ?> 257<script> 258 $("#SMTP_AUTH_PASS").hideShowPassword("infer", true); 259</script> 260<?php View::endpush() ?> 261