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