xref: /webtrees/resources/views/admin/site-mail.phtml (revision 81443e3cbe4eef5ccdcf8dae716a7e35f7417b60)
11dcac87eSGreg Roach<?php
21dcac87eSGreg Roach
30c0910bfSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
4b4144a6dSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\EmailPreferencesAction;
51dcac87eSGreg Roachuse Fisharebest\Webtrees\I18N;
63282ccecSGreg Roachuse Fisharebest\Webtrees\Webtrees;
71dcac87eSGreg Roach
81dcac87eSGreg Roach/**
91dcac87eSGreg Roach * @var string        $DKIM_DOMAIN
101dcac87eSGreg Roach * @var string        $DKIM_KEY
111dcac87eSGreg Roach * @var string        $DKIM_SELECTOR
121dcac87eSGreg Roach * @var string        $SMTP_ACTIVE
131dcac87eSGreg Roach * @var string        $SMTP_AUTH
141dcac87eSGreg Roach * @var string        $SMTP_AUTH_USER
15e2c25bffSGreg Roach * @var string        $SMTP_DISP_NAME
161dcac87eSGreg Roach * @var string        $SMTP_FROM_NAME
171dcac87eSGreg Roach * @var string        $SMTP_HELO
181dcac87eSGreg Roach * @var string        $SMTP_HOST
191dcac87eSGreg Roach * @var string        $SMTP_PORT
201dcac87eSGreg Roach * @var string        $SMTP_SSL
2109482a55SGreg Roach * @var array<string> $mail_ssl_options
2209482a55SGreg Roach * @var array<string> $mail_transport_options
231dcac87eSGreg Roach * @var bool          $smtp_helo_valid
241dcac87eSGreg Roach * @var bool          $smtp_from_name_valid
251dcac87eSGreg Roach * @var string        $title
261dcac87eSGreg Roach */
271dcac87eSGreg Roach?>
28dd6b2bfcSGreg Roach
290c0910bfSGreg Roach<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?>
30dd6b2bfcSGreg Roach
31dd6b2bfcSGreg Roach<h1><?= $title ?></h1>
32dd6b2bfcSGreg Roach
33dbc19611SGreg Roach<div class="alert alert-info">
343282ccecSGreg Roach    <?= I18N::translate('See %s for more information.', '<a class="alert-link" href="' . e(Webtrees::URL_FAQ_EMAIL) . '">' . e(Webtrees::URL_FAQ_EMAIL) . '</a>') ?>
35dbc19611SGreg Roach</div>
36dd6b2bfcSGreg Roach
37b4144a6dSGreg Roach<form method="post" action="<?= e(route(EmailPreferencesAction::class)) ?>" class="form-horizontal">
389e3c2cf9SGreg Roach    <div class="row mb-3">
39dd6b2bfcSGreg Roach        <label for="SMTP_ACTIVE" class="col-sm-3 col-form-label">
401dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
411dcac87eSGreg Roach            I18N::translate('Messages') ?>
42dd6b2bfcSGreg Roach        </label>
43dd6b2bfcSGreg Roach        <div class="col-sm-9">
441dcac87eSGreg Roach            <?= view('components/select', ['name' => 'SMTP_ACTIVE', 'selected' => $SMTP_ACTIVE, 'options' => $mail_transport_options]) ?>
45315eb316SGreg Roach            <div class="form-text">
461dcac87eSGreg Roach                <?= /* I18N: Help text for the “Messages” site configuration setting */
471dcac87eSGreg Roach                I18N::translate('webtrees needs to send emails, such as password reminders and website notifications.') ?>
48315eb316SGreg Roach            </div>
49dd6b2bfcSGreg Roach        </div>
50dd6b2bfcSGreg Roach    </div>
51dd6b2bfcSGreg Roach
529e3c2cf9SGreg Roach    <div class="row mb-3">
53e2c25bffSGreg Roach        <label for="SMTP_DISP_NAME" class="col-sm-3 col-form-label">
541dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
551dcac87eSGreg Roach            I18N::translate('Sender name') ?>
56dd6b2bfcSGreg Roach        </label>
57dd6b2bfcSGreg Roach        <div class="col-sm-9">
58e2c25bffSGreg Roach            <input type="text" class="form-control" id="SMTP_DISP_NAME" name="SMTP_DISP_NAME" value="<?= e($SMTP_DISP_NAME) ?>" maxlength="255" required="required">
59315eb316SGreg Roach            <div class="form-text">
60e2c25bffSGreg Roach                <?= /* I18N: Help text for the “Sender name” site configuration setting */
61e2c25bffSGreg Roach                I18N::translate('This name is used in the “From” field, when sending automatic emails from this server.') ?>
62315eb316SGreg Roach            </div>
63e2c25bffSGreg Roach        </div>
64e2c25bffSGreg Roach    </div>
65e2c25bffSGreg Roach
669e3c2cf9SGreg Roach    <div class="row mb-3">
67e2c25bffSGreg Roach        <label for="SMTP_FROM_NAME" class="col-sm-3 col-form-label">
68e2c25bffSGreg Roach            <?= /* I18N: A configuration setting */
69e2c25bffSGreg Roach            I18N::translate('Sender email') ?>
70e2c25bffSGreg Roach        </label>
71e2c25bffSGreg Roach        <div class="col-sm-9">
72e2c25bffSGreg Roach            <input type="email" class="form-control" id="SMTP_FROM_NAME" name="SMTP_FROM_NAME" value="<?= e($SMTP_FROM_NAME) ?>" maxlength="255" required="required">
73315eb316SGreg Roach            <div class="form-text">
741dcac87eSGreg Roach                <?= /* I18N: Help text for the “Sender name” site configuration setting */
751dcac87eSGreg Roach                I18N::translate('This name is used in the “From” field, when sending automatic emails from this server.') ?>
76315eb316SGreg Roach            </div>
771dcac87eSGreg Roach
781dcac87eSGreg Roach            <?php if (!$smtp_from_name_valid) : ?>
791dcac87eSGreg Roach                <p class="alert alert-warning">
801dcac87eSGreg Roach                    <?= I18N::translate('Most mail servers require a valid email address.') ?>
811dcac87eSGreg Roach                </p>
821dcac87eSGreg Roach            <?php endif ?>
83dd6b2bfcSGreg Roach        </div>
84dd6b2bfcSGreg Roach    </div>
85dd6b2bfcSGreg Roach
86dd6b2bfcSGreg Roach    <h2><?= I18N::translate('SMTP mail server') ?></h2>
87dd6b2bfcSGreg Roach
889e3c2cf9SGreg Roach    <div class="row mb-3">
89dd6b2bfcSGreg Roach        <label for="SMTP_HOST" class="col-sm-3 col-form-label">
901dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
911dcac87eSGreg Roach            I18N::translate('Server name') ?>
92dd6b2bfcSGreg Roach        </label>
93dd6b2bfcSGreg Roach        <div class="col-sm-9">
941dcac87eSGreg 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-]+)*">
95315eb316SGreg Roach            <div class="form-text">
961dcac87eSGreg Roach                <?= /* I18N: Help text for the “Server name” site configuration setting */
971dcac87eSGreg 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.') ?>
98315eb316SGreg Roach            </div>
99dd6b2bfcSGreg Roach        </div>
100dd6b2bfcSGreg Roach    </div>
101dd6b2bfcSGreg Roach
1029e3c2cf9SGreg Roach    <div class="row mb-3">
103dd6b2bfcSGreg Roach        <label for="SMTP_PORT" class="col-sm-3 col-form-label">
1041dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1051dcac87eSGreg Roach            I18N::translate('Port number') ?>
106dd6b2bfcSGreg Roach        </label>
107dd6b2bfcSGreg Roach        <div class="col-sm-9">
1081dcac87eSGreg Roach            <input type="text" class="form-control" id="SMTP_PORT" name="SMTP_PORT" value="<?= e($SMTP_PORT) ?>" pattern="[0-9]*" placeholder="25" maxlength="5">
109315eb316SGreg Roach            <div class="form-text">
1101dcac87eSGreg Roach                <?= /* I18N: Help text for the "Port number" site configuration setting */
1111dcac87eSGreg Roach                I18N::translate('By default, SMTP works on port 25.') ?>
112315eb316SGreg Roach            </div>
113dd6b2bfcSGreg Roach        </div>
114dd6b2bfcSGreg Roach    </div>
115dd6b2bfcSGreg Roach
1169e3c2cf9SGreg Roach    <fieldset class="row mb-3">
117dd6b2bfcSGreg Roach        <legend class="col-form-label col-sm-3">
1181dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1191dcac87eSGreg Roach            I18N::translate('Use password') ?>
120dd6b2bfcSGreg Roach        </legend>
121dd6b2bfcSGreg Roach        <div class="col-sm-9">
1221dcac87eSGreg Roach            <?= view('components/radios-inline', ['name' => 'SMTP_AUTH', 'options' => [I18N::translate('no'), I18N::translate('yes')], 'selected' => (int) $SMTP_AUTH]) ?>
123315eb316SGreg Roach            <div class="form-text">
1241dcac87eSGreg Roach                <?= /* I18N: Help text for the “Use password” site configuration setting */
1251dcac87eSGreg Roach                I18N::translate('Most SMTP servers require a password.') ?>
126dd6b2bfcSGreg Roach            </div>
127dd6b2bfcSGreg Roach        </div>
128dd6b2bfcSGreg Roach    </fieldset>
129dd6b2bfcSGreg Roach
1309e3c2cf9SGreg Roach    <div class="row mb-3">
131dd6b2bfcSGreg Roach        <label for="SMTP_AUTH_USER" class="col-sm-3 col-form-label">
1321dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1331dcac87eSGreg Roach            I18N::translate('Username') ?>
134dd6b2bfcSGreg Roach        </label>
135dd6b2bfcSGreg Roach        <div class="col-sm-9">
1361dcac87eSGreg Roach            <input type="text" class="form-control" id="SMTP_AUTH_USER" name="SMTP_AUTH_USER" value="<?= e($SMTP_AUTH_USER) ?>" maxlength="255">
137315eb316SGreg Roach            <div class="form-text">
1381dcac87eSGreg Roach                <?= /* I18N: Help text for the "Username" site configuration setting */
1391dcac87eSGreg Roach                I18N::translate('The username required for authentication with the SMTP server.') ?>
140315eb316SGreg Roach            </div>
141dd6b2bfcSGreg Roach        </div>
142dd6b2bfcSGreg Roach    </div>
143dd6b2bfcSGreg Roach
1449e3c2cf9SGreg Roach    <div class="row mb-3">
145dd6b2bfcSGreg Roach        <label for="SMTP_AUTH_PASS" class="col-sm-3 col-form-label">
1461dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1471dcac87eSGreg Roach            I18N::translate('Password') ?>
148dd6b2bfcSGreg Roach        </label>
149dd6b2bfcSGreg Roach        <div class="col-sm-9">
150d4786c66SGreg Roach            <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')) ?>">
151315eb316SGreg Roach            <div class="form-text">
1521dcac87eSGreg Roach                <?= /* I18N: Help text for the "Password" site configuration setting */
1531dcac87eSGreg Roach                I18N::translate('The password required for authentication with the SMTP server.') ?>
154315eb316SGreg Roach            </div>
155dd6b2bfcSGreg Roach        </div>
156dd6b2bfcSGreg Roach    </div>
157dd6b2bfcSGreg Roach
1589e3c2cf9SGreg Roach    <div class="row mb-3">
159dd6b2bfcSGreg Roach        <label for="SMTP_SSL" class="col-sm-3 col-form-label">
1601dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1611dcac87eSGreg Roach            I18N::translate('Secure connection') ?>
162dd6b2bfcSGreg Roach        </label>
163dd6b2bfcSGreg Roach        <div class="col-sm-9">
1641dcac87eSGreg Roach            <?= view('components/select', ['name' => 'SMTP_SSL', 'selected' => $SMTP_SSL, 'options' => $mail_ssl_options]) ?>
165315eb316SGreg Roach            <div class="form-text">
1661dcac87eSGreg Roach                <?= /* I18N: Help text for the “Secure connection” site configuration setting */
1671dcac87eSGreg Roach                I18N::translate('Most servers do not use secure connections.') ?>
168315eb316SGreg Roach            </div>
169dd6b2bfcSGreg Roach        </div>
170dd6b2bfcSGreg Roach    </div>
171dd6b2bfcSGreg Roach
1729e3c2cf9SGreg Roach    <div class="row mb-3">
173dd6b2bfcSGreg Roach        <label for="SMTP_HELO" class="col-sm-3 col-form-label">
1741dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1751dcac87eSGreg Roach            I18N::translate('Sending server name') ?>
176dd6b2bfcSGreg Roach        </label>
177dd6b2bfcSGreg Roach        <div class="col-sm-9">
1781dcac87eSGreg 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-]+)*">
179315eb316SGreg Roach            <div class="form-text">
1801dcac87eSGreg Roach                <?= /* I18N: Help text for the "Sending server name" site configuration setting */
1811dcac87eSGreg Roach                I18N::translate('Most mail servers require that the sending server identifies itself correctly, using a valid domain name.') ?>
182315eb316SGreg Roach            </div>
1831dcac87eSGreg Roach
1841dcac87eSGreg Roach            <?php if (!$smtp_helo_valid) : ?>
1851dcac87eSGreg Roach                <p class="alert alert-warning">
1861dcac87eSGreg Roach                    <?= I18N::translate('Most mail servers require a valid domain name.') ?>
1871dcac87eSGreg Roach                </p>
1881dcac87eSGreg Roach            <?php endif ?>
189dd6b2bfcSGreg Roach        </div>
190dd6b2bfcSGreg Roach    </div>
191dd6b2bfcSGreg Roach
1924d99955eSGreg Roach    <h2>
1931dcac87eSGreg Roach        <?= /* I18N: https://en.wikipedia.org/wiki/DomainKeys_Identified_Mail */
1941dcac87eSGreg Roach        I18N::translate('DKIM digital signature') ?>
1954d99955eSGreg Roach    </h2>
1964d99955eSGreg Roach
1979e3c2cf9SGreg Roach    <div class="row mb-3">
1984d99955eSGreg Roach        <label for="DKIM_DOMAIN" class="col-sm-3 col-form-label">
1994d99955eSGreg Roach            <?= I18N::translate('Domain name') ?>
2004d99955eSGreg Roach        </label>
2014d99955eSGreg Roach        <div class="col-sm-9">
2021dcac87eSGreg Roach            <input type="text" class="form-control" id="DKIM_DOMAIN" name="DKIM_DOMAIN" value="<?= e($DKIM_DOMAIN) ?>" maxlength="255">
2034d99955eSGreg Roach        </div>
2044d99955eSGreg Roach    </div>
2054d99955eSGreg Roach
2069e3c2cf9SGreg Roach    <div class="row mb-3">
2074d99955eSGreg Roach        <label for="DKIM_SELECTOR" class="col-sm-3 col-form-label">
2084d99955eSGreg Roach            <?= I18N::translate('Selector') ?>
2094d99955eSGreg Roach        </label>
2104d99955eSGreg Roach        <div class="col-sm-9">
2111dcac87eSGreg Roach            <input type="text" class="form-control" id="DKIM_SELECTOR" name="DKIM_SELECTOR" value="<?= e($DKIM_SELECTOR) ?>" maxlength="255">
2124d99955eSGreg Roach        </div>
2134d99955eSGreg Roach    </div>
2144d99955eSGreg Roach
2159e3c2cf9SGreg Roach    <div class="row mb-3">
2164d99955eSGreg Roach        <label for="DKIM_KEY" class="col-sm-3 col-form-label">
2174d99955eSGreg Roach            <?= I18N::translate('Private key') ?>
2184d99955eSGreg Roach        </label>
2194d99955eSGreg Roach        <div class="col-sm-9">
2201dcac87eSGreg Roach            <textarea class="form-control" id="DKIM_KEY" name="DKIM_KEY"><?= e($DKIM_KEY) ?></textarea>
2214d99955eSGreg Roach        </div>
2224d99955eSGreg Roach    </div>
2234d99955eSGreg Roach
2241dcac87eSGreg Roach    <hr>
2251dcac87eSGreg Roach
2269e3c2cf9SGreg Roach    <div class="row mb-3">
227dd6b2bfcSGreg Roach        <div class="offset-sm-3 col-sm-9">
228b4144a6dSGreg Roach            <p class="form-check">
229b4144a6dSGreg Roach                <input class="form-check-input" type="checkbox" id="test" name="test">
230b4144a6dSGreg Roach                <label class="form-check-label" for="test">
231b4144a6dSGreg Roach                    <?= I18N::translate('Send a test email using these settings') ?>
232b4144a6dSGreg Roach                </label>
233b4144a6dSGreg Roach            </p>
234b4144a6dSGreg Roach
235dd6b2bfcSGreg Roach            <button type="submit" class="btn btn-primary">
236dd6b2bfcSGreg Roach                <?= view('icons/save') ?>
237dd6b2bfcSGreg Roach                <?= I18N::translate('save') ?>
238dd6b2bfcSGreg Roach            </button>
239dd6b2bfcSGreg Roach
2400c0910bfSGreg Roach            <a href="<?= e(route(ControlPanel::class)) ?>" class="btn btn-secondary">
241dd6b2bfcSGreg Roach                <?= view('icons/cancel') ?>
242dd6b2bfcSGreg Roach                <?= I18N::translate('cancel') ?>
243dd6b2bfcSGreg Roach            </a>
244dd6b2bfcSGreg Roach        </div>
245dd6b2bfcSGreg Roach    </div>
246*81443e3cSGreg Roach
247*81443e3cSGreg Roach    <?= csrf_field() ?>
248dd6b2bfcSGreg Roach</form>
249