xref: /webtrees/resources/views/admin/site-mail.phtml (revision 0b5fd0a636fa959f5279ee28ebd2f27e921c091e)
1<?php use Fisharebest\Webtrees\I18N; ?>
2<?php use Fisharebest\Webtrees\Site; ?>
3<?php use Fisharebest\Webtrees\View; ?>
4
5<?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), $title]]) ?>
6
7<h1><?= $title ?></h1>
8
9<p class="alert alert-info">
10    <?= 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>' ?>
11</p>
12
13<form method="post" class="form-horizontal">
14    <?= csrf_field() ?>
15
16    <!-- SMTP_ACTIVE -->
17    <div class="row form-group">
18        <label for="SMTP_ACTIVE" class="col-sm-3 col-form-label">
19            <?= /* I18N: A configuration setting */ I18N::translate('Messages') ?>
20        </label>
21        <div class="col-sm-9">
22            <?= view('components/select', ['name' => 'SMTP_ACTIVE', 'selected' => Site::getPreference('SMTP_ACTIVE'), 'options' => $mail_transport_options]) ?>
23            <p class="small text-muted">
24                <?= /* I18N: Help text for the “Messages” site configuration setting */ I18N::translate('webtrees needs to send emails, such as password reminders and website notifications. To do this, it can use this server’s built in PHP mail facility (which is not always available) or an external SMTP (mail-relay) service, for which you will need to provide the connection details.') ?>
25            </p>
26        </div>
27    </div>
28
29    <!-- SMTP_FROM_NAME -->
30    <div class="row form-group">
31        <label for="SMTP_FROM_NAME" class="col-sm-3 col-form-label">
32            <?= /* I18N: A configuration setting */ I18N::translate('Sender name') ?>
33        </label>
34        <div class="col-sm-9">
35            <input type="email" class="form-control" id="SMTP_FROM_NAME" name="SMTP_FROM_NAME" value="<?= e(Site::getPreference('SMTP_FROM_NAME')) ?>" placeholder="no-reply@localhost" maxlength="255">
36            <p class="small text-muted">
37                <?= /* I18N: Help text for the “Sender name” site configuration setting */ I18N::translate('This name is used in the “From” field, when sending automatic emails from this server.') ?>
38            </p>
39        </div>
40    </div>
41
42    <h2><?= I18N::translate('SMTP mail server') ?></h2>
43
44    <!-- SMTP_HOST -->
45    <div class="row form-group">
46        <label for="SMTP_HOST" class="col-sm-3 col-form-label">
47            <?= /* I18N: A configuration setting */ I18N::translate('Server name') ?>
48        </label>
49        <div class="col-sm-9">
50            <input type="text" class="form-control" id="SMTP_HOST" name="SMTP_HOST" value="<?= e(Site::getPreference('SMTP_HOST')) ?>" placeholder="smtp.example.com" maxlength="255" pattern="[a-z0-9-]+(\.[a-z0-9-]+)*">
51            <p class="small text-muted">
52                <?= /* I18N: Help text for the “Server name” site configuration setting */ 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.') ?>
53            </p>
54        </div>
55    </div>
56
57    <!-- SMTP_PORT -->
58    <div class="row form-group">
59        <label for="SMTP_PORT" class="col-sm-3 col-form-label">
60            <?= /* I18N: A configuration setting */ I18N::translate('Port number') ?>
61        </label>
62        <div class="col-sm-9">
63            <input type="text" class="form-control" id="SMTP_PORT" name="SMTP_PORT" value="<?= e(Site::getPreference('SMTP_PORT')) ?>" pattern="[0-9]*" placeholder="25" maxlength="5">
64            <p class="small text-muted">
65                <?= /* I18N: Help text for the "Port number" site configuration setting */ I18N::translate('By default, SMTP works on port 25.') ?>
66            </p>
67        </div>
68    </div>
69
70    <!-- SMTP_AUTH -->
71    <fieldset class="form-group">
72        <div class="row">
73            <legend class="col-form-label col-sm-3">
74                <?= /* I18N: A configuration setting */ I18N::translate('Use password') ?>
75            </legend>
76            <div class="col-sm-9">
77                <?= view('components/radios-inline', ['name' => 'SMTP_AUTH', 'options' => [I18N::translate('no'), I18N::translate('yes')], 'selected' => (int) Site::getPreference('SMTP_AUTH')]) ?>
78                <p class="small text-muted">
79                    <?= /* I18N: Help text for the “Use password” site configuration setting */ I18N::translate('Most SMTP servers require a password.') ?>
80                </p>
81            </div>
82        </div>
83    </fieldset>
84
85    <!-- SMTP_AUTH_USER -->
86    <div class="row form-group">
87        <label for="SMTP_AUTH_USER" class="col-sm-3 col-form-label">
88            <?= /* I18N: A configuration setting */ I18N::translate('Username') ?>
89        </label>
90        <div class="col-sm-9">
91            <input type="text" class="form-control" id="SMTP_AUTH_USER" name="SMTP_AUTH_USER" value="<?= e(Site::getPreference('SMTP_AUTH_USER')) ?>" maxlength="255">
92            <p class="small text-muted">
93                <?= /* I18N: Help text for the "Username" site configuration setting */ I18N::translate('The username required for authentication with the SMTP server.') ?>
94            </p>
95        </div>
96    </div>
97
98    <!-- SMTP_AUTH_PASS -->
99    <div class="row form-group">
100        <label for="SMTP_AUTH_PASS" class="col-sm-3 col-form-label">
101            <?= /* I18N: A configuration setting */ I18N::translate('Password') ?>
102        </label>
103        <div class="col-sm-9">
104            <input type="password" class="form-control" id="SMTP_AUTH_PASS" name="SMTP_AUTH_PASS" value="">
105            <p class="small text-muted">
106                <?= /* I18N: Help text for the "Password" site configuration setting */ I18N::translate('The password required for authentication with the SMTP server.') ?>
107            </p>
108        </div>
109    </div>
110
111    <!-- SMTP_SSL -->
112    <div class="row form-group">
113        <label for="SMTP_SSL" class="col-sm-3 col-form-label">
114            <?= /* I18N: A configuration setting */ I18N::translate('Secure connection') ?>
115        </label>
116        <div class="col-sm-9">
117            <?= view('components/select', ['name' => 'SMTP_SSL', 'selected' => Site::getPreference('SMTP_SSL'), 'options' => $mail_ssl_options]) ?>
118            <p class="small text-muted">
119                <?= /* I18N: Help text for the “Secure connection” site configuration setting */ I18N::translate('Most servers do not use secure connections.') ?>
120            </p>
121        </div>
122    </div>
123
124    <!-- SMTP_HELO -->
125    <div class="row form-group">
126        <label for="SMTP_HELO" class="col-sm-3 col-form-label">
127            <?= /* I18N: A configuration setting */ I18N::translate('Sending server name') ?>
128        </label>
129        <div class="col-sm-9">
130            <input type="text" class="form-control" id="SMTP_HELO" name="SMTP_HELO" value="<?= e(Site::getPreference('SMTP_HELO')) ?>" placeholder="localhost" maxlength="255" pattern="[a-z0-9-]+(\.[a-z0-9-]+)*">
131            <p class="small text-muted">
132                <?= /* I18N: Help text for the "Sending server name" site configuration setting */ I18N::translate('Many mail servers require that the sending server identifies itself correctly, using a valid domain name.') ?>
133            </p>
134        </div>
135    </div>
136
137    <div class="row form-group">
138        <div class="offset-sm-3 col-sm-9">
139            <button type="submit" class="btn btn-primary">
140                <?= view('icons/save') ?>
141                <?= I18N::translate('save') ?>
142            </button>
143
144            <a href="<?= e(route('admin-control-panel')) ?>" class="btn btn-secondary">
145                <?= view('icons/cancel') ?>
146                <?= I18N::translate('cancel') ?>
147            </a>
148        </div>
149    </div>
150</form>
151
152<?php View::push('javascript') ?>
153<script>
154    $('#SMTP_AUTH_PASS').hideShowPassword('infer', true);
155</script>
156<?php View::endpush() ?>
157