xref: /webtrees/resources/views/admin/site-mail.phtml (revision 10e0649788c8d7d4974d81c048ca2b225df8f22e)
11dcac87eSGreg Roach<?php
21dcac87eSGreg Roach
3*10e06497SGreg Roachdeclare(strict_types=1);
4*10e06497SGreg Roach
50c0910bfSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
6b4144a6dSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\EmailPreferencesAction;
71dcac87eSGreg Roachuse Fisharebest\Webtrees\I18N;
83282ccecSGreg Roachuse Fisharebest\Webtrees\Webtrees;
91dcac87eSGreg Roach
101dcac87eSGreg Roach/**
111dcac87eSGreg Roach * @var string        $DKIM_DOMAIN
121dcac87eSGreg Roach * @var string        $DKIM_KEY
131dcac87eSGreg Roach * @var string        $DKIM_SELECTOR
141dcac87eSGreg Roach * @var string        $SMTP_ACTIVE
151dcac87eSGreg Roach * @var string        $SMTP_AUTH
161dcac87eSGreg Roach * @var string        $SMTP_AUTH_USER
17e2c25bffSGreg Roach * @var string        $SMTP_DISP_NAME
181dcac87eSGreg Roach * @var string        $SMTP_FROM_NAME
191dcac87eSGreg Roach * @var string        $SMTP_HELO
201dcac87eSGreg Roach * @var string        $SMTP_HOST
211dcac87eSGreg Roach * @var string        $SMTP_PORT
221dcac87eSGreg Roach * @var string        $SMTP_SSL
2309482a55SGreg Roach * @var array<string> $mail_ssl_options
2409482a55SGreg Roach * @var array<string> $mail_transport_options
251dcac87eSGreg Roach * @var bool          $smtp_helo_valid
261dcac87eSGreg Roach * @var bool          $smtp_from_name_valid
271dcac87eSGreg Roach * @var string        $title
281dcac87eSGreg Roach */
291dcac87eSGreg Roach?>
30dd6b2bfcSGreg Roach
310c0910bfSGreg Roach<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?>
32dd6b2bfcSGreg Roach
33dd6b2bfcSGreg Roach<h1><?= $title ?></h1>
34dd6b2bfcSGreg Roach
35dbc19611SGreg Roach<div class="alert alert-info">
363282ccecSGreg Roach    <?= I18N::translate('See %s for more information.', '<a class="alert-link" href="' . e(Webtrees::URL_FAQ_EMAIL) . '">' . e(Webtrees::URL_FAQ_EMAIL) . '</a>') ?>
37dbc19611SGreg Roach</div>
38dd6b2bfcSGreg Roach
39b4144a6dSGreg Roach<form method="post" action="<?= e(route(EmailPreferencesAction::class)) ?>" class="form-horizontal">
409e3c2cf9SGreg Roach    <div class="row mb-3">
41dd6b2bfcSGreg Roach        <label for="SMTP_ACTIVE" class="col-sm-3 col-form-label">
421dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
431dcac87eSGreg Roach            I18N::translate('Messages') ?>
44dd6b2bfcSGreg Roach        </label>
45dd6b2bfcSGreg Roach        <div class="col-sm-9">
461dcac87eSGreg Roach            <?= view('components/select', ['name' => 'SMTP_ACTIVE', 'selected' => $SMTP_ACTIVE, 'options' => $mail_transport_options]) ?>
47315eb316SGreg Roach            <div class="form-text">
481dcac87eSGreg Roach                <?= /* I18N: Help text for the “Messages” site configuration setting */
491dcac87eSGreg Roach                I18N::translate('webtrees needs to send emails, such as password reminders and website notifications.') ?>
50315eb316SGreg Roach            </div>
51dd6b2bfcSGreg Roach        </div>
52dd6b2bfcSGreg Roach    </div>
53dd6b2bfcSGreg Roach
549e3c2cf9SGreg Roach    <div class="row mb-3">
55e2c25bffSGreg Roach        <label for="SMTP_DISP_NAME" class="col-sm-3 col-form-label">
561dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
571dcac87eSGreg Roach            I18N::translate('Sender name') ?>
58dd6b2bfcSGreg Roach        </label>
59dd6b2bfcSGreg Roach        <div class="col-sm-9">
60e2c25bffSGreg Roach            <input type="text" class="form-control" id="SMTP_DISP_NAME" name="SMTP_DISP_NAME" value="<?= e($SMTP_DISP_NAME) ?>" maxlength="255" required="required">
61315eb316SGreg Roach            <div class="form-text">
62e2c25bffSGreg Roach                <?= /* I18N: Help text for the “Sender name” site configuration setting */
63e2c25bffSGreg Roach                I18N::translate('This name is used in the “From” field, when sending automatic emails from this server.') ?>
64315eb316SGreg Roach            </div>
65e2c25bffSGreg Roach        </div>
66e2c25bffSGreg Roach    </div>
67e2c25bffSGreg Roach
689e3c2cf9SGreg Roach    <div class="row mb-3">
69e2c25bffSGreg Roach        <label for="SMTP_FROM_NAME" class="col-sm-3 col-form-label">
70e2c25bffSGreg Roach            <?= /* I18N: A configuration setting */
71e2c25bffSGreg Roach            I18N::translate('Sender email') ?>
72e2c25bffSGreg Roach        </label>
73e2c25bffSGreg Roach        <div class="col-sm-9">
74e2c25bffSGreg Roach            <input type="email" class="form-control" id="SMTP_FROM_NAME" name="SMTP_FROM_NAME" value="<?= e($SMTP_FROM_NAME) ?>" maxlength="255" required="required">
75315eb316SGreg Roach            <div class="form-text">
761dcac87eSGreg Roach                <?= /* I18N: Help text for the “Sender name” site configuration setting */
771dcac87eSGreg Roach                I18N::translate('This name is used in the “From” field, when sending automatic emails from this server.') ?>
78315eb316SGreg Roach            </div>
791dcac87eSGreg Roach
801dcac87eSGreg Roach            <?php if (!$smtp_from_name_valid) : ?>
811dcac87eSGreg Roach                <p class="alert alert-warning">
821dcac87eSGreg Roach                    <?= I18N::translate('Most mail servers require a valid email address.') ?>
831dcac87eSGreg Roach                </p>
841dcac87eSGreg Roach            <?php endif ?>
85dd6b2bfcSGreg Roach        </div>
86dd6b2bfcSGreg Roach    </div>
87dd6b2bfcSGreg Roach
88dd6b2bfcSGreg Roach    <h2><?= I18N::translate('SMTP mail server') ?></h2>
89dd6b2bfcSGreg Roach
909e3c2cf9SGreg Roach    <div class="row mb-3">
91dd6b2bfcSGreg Roach        <label for="SMTP_HOST" class="col-sm-3 col-form-label">
921dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
931dcac87eSGreg Roach            I18N::translate('Server name') ?>
94dd6b2bfcSGreg Roach        </label>
95dd6b2bfcSGreg Roach        <div class="col-sm-9">
961dcac87eSGreg 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-]+)*">
97315eb316SGreg Roach            <div class="form-text">
981dcac87eSGreg Roach                <?= /* I18N: Help text for the “Server name” site configuration setting */
991dcac87eSGreg 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.') ?>
100315eb316SGreg Roach            </div>
101dd6b2bfcSGreg Roach        </div>
102dd6b2bfcSGreg Roach    </div>
103dd6b2bfcSGreg Roach
1049e3c2cf9SGreg Roach    <div class="row mb-3">
105dd6b2bfcSGreg Roach        <label for="SMTP_PORT" class="col-sm-3 col-form-label">
1061dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1071dcac87eSGreg Roach            I18N::translate('Port number') ?>
108dd6b2bfcSGreg Roach        </label>
109dd6b2bfcSGreg Roach        <div class="col-sm-9">
1101dcac87eSGreg Roach            <input type="text" class="form-control" id="SMTP_PORT" name="SMTP_PORT" value="<?= e($SMTP_PORT) ?>" pattern="[0-9]*" placeholder="25" maxlength="5">
111315eb316SGreg Roach            <div class="form-text">
1121dcac87eSGreg Roach                <?= /* I18N: Help text for the "Port number" site configuration setting */
1131dcac87eSGreg Roach                I18N::translate('By default, SMTP works on port 25.') ?>
114315eb316SGreg Roach            </div>
115dd6b2bfcSGreg Roach        </div>
116dd6b2bfcSGreg Roach    </div>
117dd6b2bfcSGreg Roach
1189e3c2cf9SGreg Roach    <fieldset class="row mb-3">
119dd6b2bfcSGreg Roach        <legend class="col-form-label col-sm-3">
1201dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1211dcac87eSGreg Roach            I18N::translate('Use password') ?>
122dd6b2bfcSGreg Roach        </legend>
123dd6b2bfcSGreg Roach        <div class="col-sm-9">
1241dcac87eSGreg Roach            <?= view('components/radios-inline', ['name' => 'SMTP_AUTH', 'options' => [I18N::translate('no'), I18N::translate('yes')], 'selected' => (int) $SMTP_AUTH]) ?>
125315eb316SGreg Roach            <div class="form-text">
1261dcac87eSGreg Roach                <?= /* I18N: Help text for the “Use password” site configuration setting */
1271dcac87eSGreg Roach                I18N::translate('Most SMTP servers require a password.') ?>
128dd6b2bfcSGreg Roach            </div>
129dd6b2bfcSGreg Roach        </div>
130dd6b2bfcSGreg Roach    </fieldset>
131dd6b2bfcSGreg Roach
1329e3c2cf9SGreg Roach    <div class="row mb-3">
133dd6b2bfcSGreg Roach        <label for="SMTP_AUTH_USER" class="col-sm-3 col-form-label">
1341dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1351dcac87eSGreg Roach            I18N::translate('Username') ?>
136dd6b2bfcSGreg Roach        </label>
137dd6b2bfcSGreg Roach        <div class="col-sm-9">
1381dcac87eSGreg Roach            <input type="text" class="form-control" id="SMTP_AUTH_USER" name="SMTP_AUTH_USER" value="<?= e($SMTP_AUTH_USER) ?>" maxlength="255">
139315eb316SGreg Roach            <div class="form-text">
1401dcac87eSGreg Roach                <?= /* I18N: Help text for the "Username" site configuration setting */
1411dcac87eSGreg Roach                I18N::translate('The username required for authentication with the SMTP server.') ?>
142315eb316SGreg Roach            </div>
143dd6b2bfcSGreg Roach        </div>
144dd6b2bfcSGreg Roach    </div>
145dd6b2bfcSGreg Roach
1469e3c2cf9SGreg Roach    <div class="row mb-3">
147dd6b2bfcSGreg Roach        <label for="SMTP_AUTH_PASS" class="col-sm-3 col-form-label">
1481dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1491dcac87eSGreg Roach            I18N::translate('Password') ?>
150dd6b2bfcSGreg Roach        </label>
151dd6b2bfcSGreg Roach        <div class="col-sm-9">
152d4786c66SGreg 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')) ?>">
153315eb316SGreg Roach            <div class="form-text">
1541dcac87eSGreg Roach                <?= /* I18N: Help text for the "Password" site configuration setting */
1551dcac87eSGreg Roach                I18N::translate('The password required for authentication with the SMTP server.') ?>
156315eb316SGreg Roach            </div>
157dd6b2bfcSGreg Roach        </div>
158dd6b2bfcSGreg Roach    </div>
159dd6b2bfcSGreg Roach
1609e3c2cf9SGreg Roach    <div class="row mb-3">
161dd6b2bfcSGreg Roach        <label for="SMTP_SSL" class="col-sm-3 col-form-label">
1621dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1631dcac87eSGreg Roach            I18N::translate('Secure connection') ?>
164dd6b2bfcSGreg Roach        </label>
165dd6b2bfcSGreg Roach        <div class="col-sm-9">
1661dcac87eSGreg Roach            <?= view('components/select', ['name' => 'SMTP_SSL', 'selected' => $SMTP_SSL, 'options' => $mail_ssl_options]) ?>
167315eb316SGreg Roach            <div class="form-text">
1681dcac87eSGreg Roach                <?= /* I18N: Help text for the “Secure connection” site configuration setting */
1691dcac87eSGreg Roach                I18N::translate('Most servers do not use secure connections.') ?>
170315eb316SGreg Roach            </div>
171dd6b2bfcSGreg Roach        </div>
172dd6b2bfcSGreg Roach    </div>
173dd6b2bfcSGreg Roach
1749e3c2cf9SGreg Roach    <div class="row mb-3">
175dd6b2bfcSGreg Roach        <label for="SMTP_HELO" class="col-sm-3 col-form-label">
1761dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1771dcac87eSGreg Roach            I18N::translate('Sending server name') ?>
178dd6b2bfcSGreg Roach        </label>
179dd6b2bfcSGreg Roach        <div class="col-sm-9">
1801dcac87eSGreg 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-]+)*">
181315eb316SGreg Roach            <div class="form-text">
1821dcac87eSGreg Roach                <?= /* I18N: Help text for the "Sending server name" site configuration setting */
1831dcac87eSGreg Roach                I18N::translate('Most mail servers require that the sending server identifies itself correctly, using a valid domain name.') ?>
184315eb316SGreg Roach            </div>
1851dcac87eSGreg Roach
1861dcac87eSGreg Roach            <?php if (!$smtp_helo_valid) : ?>
1871dcac87eSGreg Roach                <p class="alert alert-warning">
1881dcac87eSGreg Roach                    <?= I18N::translate('Most mail servers require a valid domain name.') ?>
1891dcac87eSGreg Roach                </p>
1901dcac87eSGreg Roach            <?php endif ?>
191dd6b2bfcSGreg Roach        </div>
192dd6b2bfcSGreg Roach    </div>
193dd6b2bfcSGreg Roach
1944d99955eSGreg Roach    <h2>
1951dcac87eSGreg Roach        <?= /* I18N: https://en.wikipedia.org/wiki/DomainKeys_Identified_Mail */
1961dcac87eSGreg Roach        I18N::translate('DKIM digital signature') ?>
1974d99955eSGreg Roach    </h2>
1984d99955eSGreg Roach
1999e3c2cf9SGreg Roach    <div class="row mb-3">
2004d99955eSGreg Roach        <label for="DKIM_DOMAIN" class="col-sm-3 col-form-label">
2014d99955eSGreg Roach            <?= I18N::translate('Domain name') ?>
2024d99955eSGreg Roach        </label>
2034d99955eSGreg Roach        <div class="col-sm-9">
2041dcac87eSGreg Roach            <input type="text" class="form-control" id="DKIM_DOMAIN" name="DKIM_DOMAIN" value="<?= e($DKIM_DOMAIN) ?>" maxlength="255">
2054d99955eSGreg Roach        </div>
2064d99955eSGreg Roach    </div>
2074d99955eSGreg Roach
2089e3c2cf9SGreg Roach    <div class="row mb-3">
2094d99955eSGreg Roach        <label for="DKIM_SELECTOR" class="col-sm-3 col-form-label">
2104d99955eSGreg Roach            <?= I18N::translate('Selector') ?>
2114d99955eSGreg Roach        </label>
2124d99955eSGreg Roach        <div class="col-sm-9">
2131dcac87eSGreg Roach            <input type="text" class="form-control" id="DKIM_SELECTOR" name="DKIM_SELECTOR" value="<?= e($DKIM_SELECTOR) ?>" maxlength="255">
2144d99955eSGreg Roach        </div>
2154d99955eSGreg Roach    </div>
2164d99955eSGreg Roach
2179e3c2cf9SGreg Roach    <div class="row mb-3">
2184d99955eSGreg Roach        <label for="DKIM_KEY" class="col-sm-3 col-form-label">
2194d99955eSGreg Roach            <?= I18N::translate('Private key') ?>
2204d99955eSGreg Roach        </label>
2214d99955eSGreg Roach        <div class="col-sm-9">
2221dcac87eSGreg Roach            <textarea class="form-control" id="DKIM_KEY" name="DKIM_KEY"><?= e($DKIM_KEY) ?></textarea>
2234d99955eSGreg Roach        </div>
2244d99955eSGreg Roach    </div>
2254d99955eSGreg Roach
2261dcac87eSGreg Roach    <hr>
2271dcac87eSGreg Roach
2289e3c2cf9SGreg Roach    <div class="row mb-3">
229dd6b2bfcSGreg Roach        <div class="offset-sm-3 col-sm-9">
230b4144a6dSGreg Roach            <p class="form-check">
231b4144a6dSGreg Roach                <input class="form-check-input" type="checkbox" id="test" name="test">
232b4144a6dSGreg Roach                <label class="form-check-label" for="test">
233b4144a6dSGreg Roach                    <?= I18N::translate('Send a test email using these settings') ?>
234b4144a6dSGreg Roach                </label>
235b4144a6dSGreg Roach            </p>
236b4144a6dSGreg Roach
237dd6b2bfcSGreg Roach            <button type="submit" class="btn btn-primary">
238dd6b2bfcSGreg Roach                <?= view('icons/save') ?>
239dd6b2bfcSGreg Roach                <?= I18N::translate('save') ?>
240dd6b2bfcSGreg Roach            </button>
241dd6b2bfcSGreg Roach
2420c0910bfSGreg Roach            <a href="<?= e(route(ControlPanel::class)) ?>" class="btn btn-secondary">
243dd6b2bfcSGreg Roach                <?= view('icons/cancel') ?>
244dd6b2bfcSGreg Roach                <?= I18N::translate('cancel') ?>
245dd6b2bfcSGreg Roach            </a>
246dd6b2bfcSGreg Roach        </div>
247dd6b2bfcSGreg Roach    </div>
24881443e3cSGreg Roach
24981443e3cSGreg Roach    <?= csrf_field() ?>
250dd6b2bfcSGreg Roach</form>
251