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