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