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