xref: /webtrees/resources/views/admin/site-mail.phtml (revision e2c25bff1df9f73d83f52064d425e7d2c31fb5fe)
11dcac87eSGreg Roach<?php
21dcac87eSGreg Roach
30c0910bfSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
4b4144a6dSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\EmailPreferencesAction;
51dcac87eSGreg Roachuse Fisharebest\Webtrees\I18N;
61dcac87eSGreg Roachuse Fisharebest\Webtrees\View;
73282ccecSGreg Roachuse Fisharebest\Webtrees\Webtrees;
81dcac87eSGreg Roach
91dcac87eSGreg Roach/**
101dcac87eSGreg Roach * @var string   $DKIM_DOMAIN
111dcac87eSGreg Roach * @var string   $DKIM_KEY
121dcac87eSGreg Roach * @var string   $DKIM_SELECTOR
131dcac87eSGreg Roach * @var string   $SMTP_ACTIVE
141dcac87eSGreg Roach * @var string   $SMTP_AUTH
151dcac87eSGreg Roach * @var string   $SMTP_AUTH_USER
16*e2c25bffSGreg Roach * @var string   $SMTP_DISP_NAME
171dcac87eSGreg Roach * @var string   $SMTP_FROM_NAME
181dcac87eSGreg Roach * @var string   $SMTP_HELO
191dcac87eSGreg Roach * @var string   $SMTP_HOST
201dcac87eSGreg Roach * @var string   $SMTP_PORT
211dcac87eSGreg Roach * @var string   $SMTP_SSL
221dcac87eSGreg Roach * @var string[] $mail_ssl_options
231dcac87eSGreg Roach * @var string[] $mail_transport_options
241dcac87eSGreg Roach * @var bool     $smtp_helo_valid
251dcac87eSGreg Roach * @var bool     $smtp_from_name_valid
261dcac87eSGreg Roach * @var string   $title
271dcac87eSGreg Roach */
281dcac87eSGreg Roach?>
29dd6b2bfcSGreg Roach
300c0910bfSGreg Roach<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?>
31dd6b2bfcSGreg Roach
32dd6b2bfcSGreg Roach<h1><?= $title ?></h1>
33dd6b2bfcSGreg Roach
34dbc19611SGreg Roach<div class="alert alert-info">
353282ccecSGreg Roach    <?= I18N::translate('See %s for more information.', '<a class="alert-link" href="' . e(Webtrees::URL_FAQ_EMAIL) . '">' . e(Webtrees::URL_FAQ_EMAIL) . '</a>') ?>
36dbc19611SGreg Roach</div>
37dd6b2bfcSGreg Roach
38b4144a6dSGreg Roach<form method="post" action="<?= e(route(EmailPreferencesAction::class)) ?>" class="form-horizontal">
39dd6b2bfcSGreg Roach    <?= csrf_field() ?>
40dd6b2bfcSGreg Roach
41dd6b2bfcSGreg Roach    <div class="row form-group">
42dd6b2bfcSGreg Roach        <label for="SMTP_ACTIVE" class="col-sm-3 col-form-label">
431dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
441dcac87eSGreg Roach            I18N::translate('Messages') ?>
45dd6b2bfcSGreg Roach        </label>
46dd6b2bfcSGreg Roach        <div class="col-sm-9">
471dcac87eSGreg Roach            <?= view('components/select', ['name' => 'SMTP_ACTIVE', 'selected' => $SMTP_ACTIVE, 'options' => $mail_transport_options]) ?>
48dd6b2bfcSGreg Roach            <p class="small text-muted">
491dcac87eSGreg Roach                <?= /* I18N: Help text for the “Messages” site configuration setting */
501dcac87eSGreg Roach                I18N::translate('webtrees needs to send emails, such as password reminders and website notifications.') ?>
51dd6b2bfcSGreg Roach            </p>
52dd6b2bfcSGreg Roach        </div>
53dd6b2bfcSGreg Roach    </div>
54dd6b2bfcSGreg Roach
55dd6b2bfcSGreg Roach    <div class="row form-group">
56*e2c25bffSGreg Roach        <label for="SMTP_DISP_NAME" class="col-sm-3 col-form-label">
571dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
581dcac87eSGreg Roach            I18N::translate('Sender name') ?>
59dd6b2bfcSGreg Roach        </label>
60dd6b2bfcSGreg Roach        <div class="col-sm-9">
61*e2c25bffSGreg Roach            <input type="text" class="form-control" id="SMTP_DISP_NAME" name="SMTP_DISP_NAME" value="<?= e($SMTP_DISP_NAME) ?>" maxlength="255" required="required">
62*e2c25bffSGreg Roach            <p class="small text-muted">
63*e2c25bffSGreg Roach                <?= /* I18N: Help text for the “Sender name” site configuration setting */
64*e2c25bffSGreg Roach                I18N::translate('This name is used in the “From” field, when sending automatic emails from this server.') ?>
65*e2c25bffSGreg Roach            </p>
66*e2c25bffSGreg Roach        </div>
67*e2c25bffSGreg Roach    </div>
68*e2c25bffSGreg Roach
69*e2c25bffSGreg Roach    <div class="row form-group">
70*e2c25bffSGreg Roach        <label for="SMTP_FROM_NAME" class="col-sm-3 col-form-label">
71*e2c25bffSGreg Roach            <?= /* I18N: A configuration setting */
72*e2c25bffSGreg Roach            I18N::translate('Sender email') ?>
73*e2c25bffSGreg Roach        </label>
74*e2c25bffSGreg Roach        <div class="col-sm-9">
75*e2c25bffSGreg Roach            <input type="email" class="form-control" id="SMTP_FROM_NAME" name="SMTP_FROM_NAME" value="<?= e($SMTP_FROM_NAME) ?>" maxlength="255" required="required">
76dd6b2bfcSGreg Roach            <p class="small text-muted">
771dcac87eSGreg Roach                <?= /* I18N: Help text for the “Sender name” site configuration setting */
781dcac87eSGreg Roach                I18N::translate('This name is used in the “From” field, when sending automatic emails from this server.') ?>
79dd6b2bfcSGreg Roach            </p>
801dcac87eSGreg Roach
811dcac87eSGreg Roach            <?php if (!$smtp_from_name_valid) : ?>
821dcac87eSGreg Roach                <p class="alert alert-warning">
831dcac87eSGreg Roach                    <?= I18N::translate('Most mail servers require a valid email address.') ?>
841dcac87eSGreg Roach                </p>
851dcac87eSGreg Roach            <?php endif ?>
86dd6b2bfcSGreg Roach        </div>
87dd6b2bfcSGreg Roach    </div>
88dd6b2bfcSGreg Roach
89dd6b2bfcSGreg Roach    <h2><?= I18N::translate('SMTP mail server') ?></h2>
90dd6b2bfcSGreg Roach
91dd6b2bfcSGreg Roach    <div class="row form-group">
92dd6b2bfcSGreg Roach        <label for="SMTP_HOST" class="col-sm-3 col-form-label">
931dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
941dcac87eSGreg Roach            I18N::translate('Server name') ?>
95dd6b2bfcSGreg Roach        </label>
96dd6b2bfcSGreg Roach        <div class="col-sm-9">
971dcac87eSGreg Roach            <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-]+)*">
98dd6b2bfcSGreg Roach            <p class="small text-muted">
991dcac87eSGreg Roach                <?= /* I18N: Help text for the “Server name” site configuration setting */
1001dcac87eSGreg Roach                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.') ?>
101dd6b2bfcSGreg Roach            </p>
102dd6b2bfcSGreg Roach        </div>
103dd6b2bfcSGreg Roach    </div>
104dd6b2bfcSGreg Roach
105dd6b2bfcSGreg Roach    <div class="row form-group">
106dd6b2bfcSGreg Roach        <label for="SMTP_PORT" class="col-sm-3 col-form-label">
1071dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1081dcac87eSGreg Roach            I18N::translate('Port number') ?>
109dd6b2bfcSGreg Roach        </label>
110dd6b2bfcSGreg Roach        <div class="col-sm-9">
1111dcac87eSGreg Roach            <input type="text" class="form-control" id="SMTP_PORT" name="SMTP_PORT" value="<?= e($SMTP_PORT) ?>" pattern="[0-9]*" placeholder="25" maxlength="5">
112dd6b2bfcSGreg Roach            <p class="small text-muted">
1131dcac87eSGreg Roach                <?= /* I18N: Help text for the "Port number" site configuration setting */
1141dcac87eSGreg Roach                I18N::translate('By default, SMTP works on port 25.') ?>
115dd6b2bfcSGreg Roach            </p>
116dd6b2bfcSGreg Roach        </div>
117dd6b2bfcSGreg Roach    </div>
118dd6b2bfcSGreg Roach
119dd6b2bfcSGreg Roach    <fieldset class="form-group">
120dd6b2bfcSGreg Roach        <div class="row">
121dd6b2bfcSGreg Roach            <legend class="col-form-label col-sm-3">
1221dcac87eSGreg Roach                <?= /* I18N: A configuration setting */
1231dcac87eSGreg Roach                I18N::translate('Use password') ?>
124dd6b2bfcSGreg Roach            </legend>
125dd6b2bfcSGreg Roach            <div class="col-sm-9">
1261dcac87eSGreg Roach                <?= view('components/radios-inline', ['name' => 'SMTP_AUTH', 'options' => [I18N::translate('no'), I18N::translate('yes')], 'selected' => (int) $SMTP_AUTH]) ?>
127dd6b2bfcSGreg Roach                <p class="small text-muted">
1281dcac87eSGreg Roach                    <?= /* I18N: Help text for the “Use password” site configuration setting */
1291dcac87eSGreg Roach                    I18N::translate('Most SMTP servers require a password.') ?>
130dd6b2bfcSGreg Roach                </p>
131dd6b2bfcSGreg Roach            </div>
132dd6b2bfcSGreg Roach        </div>
133dd6b2bfcSGreg Roach    </fieldset>
134dd6b2bfcSGreg Roach
135dd6b2bfcSGreg Roach    <div class="row form-group">
136dd6b2bfcSGreg Roach        <label for="SMTP_AUTH_USER" class="col-sm-3 col-form-label">
1371dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1381dcac87eSGreg Roach            I18N::translate('Username') ?>
139dd6b2bfcSGreg Roach        </label>
140dd6b2bfcSGreg Roach        <div class="col-sm-9">
1411dcac87eSGreg Roach            <input type="text" class="form-control" id="SMTP_AUTH_USER" name="SMTP_AUTH_USER" value="<?= e($SMTP_AUTH_USER) ?>" maxlength="255">
142dd6b2bfcSGreg Roach            <p class="small text-muted">
1431dcac87eSGreg Roach                <?= /* I18N: Help text for the "Username" site configuration setting */
1441dcac87eSGreg Roach                I18N::translate('The username required for authentication with the SMTP server.') ?>
145dd6b2bfcSGreg Roach            </p>
146dd6b2bfcSGreg Roach        </div>
147dd6b2bfcSGreg Roach    </div>
148dd6b2bfcSGreg Roach
149dd6b2bfcSGreg Roach    <div class="row form-group">
150dd6b2bfcSGreg Roach        <label for="SMTP_AUTH_PASS" class="col-sm-3 col-form-label">
1511dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1521dcac87eSGreg Roach            I18N::translate('Password') ?>
153dd6b2bfcSGreg Roach        </label>
154dd6b2bfcSGreg Roach        <div class="col-sm-9">
1559105309cSGreg Roach            <input type="password" class="form-control" id="SMTP_AUTH_PASS" name="SMTP_AUTH_PASS" value="" autocomplete="new-password">
156dd6b2bfcSGreg Roach            <p class="small text-muted">
1571dcac87eSGreg Roach                <?= /* I18N: Help text for the "Password" site configuration setting */
1581dcac87eSGreg Roach                I18N::translate('The password required for authentication with the SMTP server.') ?>
159dd6b2bfcSGreg Roach            </p>
160dd6b2bfcSGreg Roach        </div>
161dd6b2bfcSGreg Roach    </div>
162dd6b2bfcSGreg Roach
163dd6b2bfcSGreg Roach    <div class="row form-group">
164dd6b2bfcSGreg Roach        <label for="SMTP_SSL" class="col-sm-3 col-form-label">
1651dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1661dcac87eSGreg Roach            I18N::translate('Secure connection') ?>
167dd6b2bfcSGreg Roach        </label>
168dd6b2bfcSGreg Roach        <div class="col-sm-9">
1691dcac87eSGreg Roach            <?= view('components/select', ['name' => 'SMTP_SSL', 'selected' => $SMTP_SSL, 'options' => $mail_ssl_options]) ?>
170dd6b2bfcSGreg Roach            <p class="small text-muted">
1711dcac87eSGreg Roach                <?= /* I18N: Help text for the “Secure connection” site configuration setting */
1721dcac87eSGreg Roach                I18N::translate('Most servers do not use secure connections.') ?>
173dd6b2bfcSGreg Roach            </p>
174dd6b2bfcSGreg Roach        </div>
175dd6b2bfcSGreg Roach    </div>
176dd6b2bfcSGreg Roach
177dd6b2bfcSGreg Roach    <div class="row form-group">
178dd6b2bfcSGreg Roach        <label for="SMTP_HELO" class="col-sm-3 col-form-label">
1791dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1801dcac87eSGreg Roach            I18N::translate('Sending server name') ?>
181dd6b2bfcSGreg Roach        </label>
182dd6b2bfcSGreg Roach        <div class="col-sm-9">
1831dcac87eSGreg Roach            <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-]+)*">
184dd6b2bfcSGreg Roach            <p class="small text-muted">
1851dcac87eSGreg Roach                <?= /* I18N: Help text for the "Sending server name" site configuration setting */
1861dcac87eSGreg Roach                I18N::translate('Most mail servers require that the sending server identifies itself correctly, using a valid domain name.') ?>
187dd6b2bfcSGreg Roach            </p>
1881dcac87eSGreg Roach
1891dcac87eSGreg Roach            <?php if (!$smtp_helo_valid) : ?>
1901dcac87eSGreg Roach                <p class="alert alert-warning">
1911dcac87eSGreg Roach                    <?= I18N::translate('Most mail servers require a valid domain name.') ?>
1921dcac87eSGreg Roach                </p>
1931dcac87eSGreg Roach            <?php endif ?>
194dd6b2bfcSGreg Roach        </div>
195dd6b2bfcSGreg Roach    </div>
196dd6b2bfcSGreg Roach
1974d99955eSGreg Roach    <h2>
1981dcac87eSGreg Roach        <?= /* I18N: https://en.wikipedia.org/wiki/DomainKeys_Identified_Mail */
1991dcac87eSGreg Roach        I18N::translate('DKIM digital signature') ?>
2004d99955eSGreg Roach    </h2>
2014d99955eSGreg Roach
2024d99955eSGreg Roach    <div class="row form-group">
2034d99955eSGreg Roach        <label for="DKIM_DOMAIN" class="col-sm-3 col-form-label">
2044d99955eSGreg Roach            <?= I18N::translate('Domain name') ?>
2054d99955eSGreg Roach        </label>
2064d99955eSGreg Roach        <div class="col-sm-9">
2071dcac87eSGreg Roach            <input type="text" class="form-control" id="DKIM_DOMAIN" name="DKIM_DOMAIN" value="<?= e($DKIM_DOMAIN) ?>" maxlength="255">
2084d99955eSGreg Roach        </div>
2094d99955eSGreg Roach    </div>
2104d99955eSGreg Roach
2114d99955eSGreg Roach    <div class="row form-group">
2124d99955eSGreg Roach        <label for="DKIM_SELECTOR" class="col-sm-3 col-form-label">
2134d99955eSGreg Roach            <?= I18N::translate('Selector') ?>
2144d99955eSGreg Roach        </label>
2154d99955eSGreg Roach        <div class="col-sm-9">
2161dcac87eSGreg Roach            <input type="text" class="form-control" id="DKIM_SELECTOR" name="DKIM_SELECTOR" value="<?= e($DKIM_SELECTOR) ?>" maxlength="255">
2174d99955eSGreg Roach        </div>
2184d99955eSGreg Roach    </div>
2194d99955eSGreg Roach
2204d99955eSGreg Roach    <div class="row form-group">
2214d99955eSGreg Roach        <label for="DKIM_KEY" class="col-sm-3 col-form-label">
2224d99955eSGreg Roach            <?= I18N::translate('Private key') ?>
2234d99955eSGreg Roach        </label>
2244d99955eSGreg Roach        <div class="col-sm-9">
2251dcac87eSGreg Roach            <textarea class="form-control" id="DKIM_KEY" name="DKIM_KEY"><?= e($DKIM_KEY) ?></textarea>
2264d99955eSGreg Roach        </div>
2274d99955eSGreg Roach    </div>
2284d99955eSGreg Roach
2291dcac87eSGreg Roach    <hr>
2301dcac87eSGreg Roach
231dd6b2bfcSGreg Roach    <div class="row form-group">
232dd6b2bfcSGreg Roach        <div class="offset-sm-3 col-sm-9">
233b4144a6dSGreg Roach            <p class="form-check">
234b4144a6dSGreg Roach                <input class="form-check-input" type="checkbox" id="test" name="test">
235b4144a6dSGreg Roach                <label class="form-check-label" for="test">
236b4144a6dSGreg Roach                    <?= I18N::translate('Send a test email using these settings') ?>
237b4144a6dSGreg Roach                </label>
238b4144a6dSGreg Roach            </p>
239b4144a6dSGreg Roach
240dd6b2bfcSGreg Roach            <button type="submit" class="btn btn-primary">
241dd6b2bfcSGreg Roach                <?= view('icons/save') ?>
242dd6b2bfcSGreg Roach                <?= I18N::translate('save') ?>
243dd6b2bfcSGreg Roach            </button>
244dd6b2bfcSGreg Roach
2450c0910bfSGreg Roach            <a href="<?= e(route(ControlPanel::class)) ?>" class="btn btn-secondary">
246dd6b2bfcSGreg Roach                <?= view('icons/cancel') ?>
247dd6b2bfcSGreg Roach                <?= I18N::translate('cancel') ?>
248dd6b2bfcSGreg Roach            </a>
249dd6b2bfcSGreg Roach        </div>
250dd6b2bfcSGreg Roach    </div>
251dd6b2bfcSGreg Roach</form>
252510d3f2fSGreg Roach
253510d3f2fSGreg Roach<?php View::push('javascript') ?>
254510d3f2fSGreg Roach<script>
2551dcac87eSGreg Roach    $("#SMTP_AUTH_PASS").hideShowPassword("infer", true);
256510d3f2fSGreg Roach</script>
257510d3f2fSGreg Roach<?php View::endpush() ?>
258