xref: /webtrees/resources/views/admin/site-mail.phtml (revision b4144a6daa0ef63a3c936d7bce4cdd925efc2a2c)
11dcac87eSGreg Roach<?php
21dcac87eSGreg Roach
30c0910bfSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
4*b4144a6dSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\EmailPreferencesAction;
51dcac87eSGreg Roachuse Fisharebest\Webtrees\I18N;
61dcac87eSGreg Roachuse Fisharebest\Webtrees\View;
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
151dcac87eSGreg Roach * @var string   $SMTP_FROM_NAME
161dcac87eSGreg Roach * @var string   $SMTP_HELO
171dcac87eSGreg Roach * @var string   $SMTP_HOST
181dcac87eSGreg Roach * @var string   $SMTP_PORT
191dcac87eSGreg Roach * @var string   $SMTP_SSL
201dcac87eSGreg Roach * @var string[] $mail_ssl_options
211dcac87eSGreg Roach * @var string[] $mail_transport_options
221dcac87eSGreg Roach * @var bool     $smtp_helo_valid
231dcac87eSGreg Roach * @var bool     $smtp_from_name_valid
241dcac87eSGreg Roach * @var string   $title
251dcac87eSGreg Roach */
261dcac87eSGreg Roach?>
27dd6b2bfcSGreg Roach
280c0910bfSGreg Roach<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?>
29dd6b2bfcSGreg Roach
30dd6b2bfcSGreg Roach<h1><?= $title ?></h1>
31dd6b2bfcSGreg Roach
32dbc19611SGreg Roach<div class="alert alert-info">
33dbc19611SGreg Roach    <a class="alert-link" data-toggle="collapse" href="#gmail-instructions" role="button" aria-expanded="false" aria-controls="gmail-instructions">
34dbc19611SGreg Roach        <?= I18N::translate('Instructions for Google mail') ?>
35dbc19611SGreg Roach    </a>
36dbc19611SGreg Roach
37dbc19611SGreg Roach    <dl class="collapse" id="gmail-instructions">
38dbc19611SGreg Roach        <dt><?= I18N::translate('Server name') ?></dt>
39dbc19611SGreg Roach        <dd>smtp.gmail.com</dd>
40dbc19611SGreg Roach        <dt><?= I18N::translate('Port number') ?></dt>
41dbc19611SGreg Roach        <dd>587</dd>
42dbc19611SGreg Roach        <dt><?= I18N::translate('Secure connection') ?></dt>
43dbc19611SGreg Roach        <dd><?= I18N::translate('tls') ?></dd>
44dbc19611SGreg Roach        <dt><?= I18N::translate('Username') ?></dt>
45dbc19611SGreg Roach        <dd>xxxxx@gmail.com</dd>
46dbc19611SGreg Roach        <dt><?= I18N::translate('Password') ?></dt>
47dbc19611SGreg Roach        <dd>
48dbc19611SGreg Roach            <?= I18N::translate('If you use two-factor authentication, create an <a href="https://myaccount.google.com/apppasswords">app password</a>.') ?>
49dbc19611SGreg Roach            <br>
50dbc19611SGreg Roach            <?= I18N::translate('If you do not use two-factor authentication, enable <a href="https://www.google.com/settings/security/lesssecureapps">less secure applications</a> and use your Google password.') ?>
51dbc19611SGreg Roach        </dd>
52dbc19611SGreg Roach    </dl>
53dbc19611SGreg Roach</div>
54dd6b2bfcSGreg Roach
55*b4144a6dSGreg Roach<form method="post" action="<?= e(route(EmailPreferencesAction::class)) ?>" class="form-horizontal">
56dd6b2bfcSGreg Roach    <?= csrf_field() ?>
57dd6b2bfcSGreg Roach
58dd6b2bfcSGreg Roach    <div class="row form-group">
59dd6b2bfcSGreg Roach        <label for="SMTP_ACTIVE" class="col-sm-3 col-form-label">
601dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
611dcac87eSGreg Roach            I18N::translate('Messages') ?>
62dd6b2bfcSGreg Roach        </label>
63dd6b2bfcSGreg Roach        <div class="col-sm-9">
641dcac87eSGreg Roach            <?= view('components/select', ['name' => 'SMTP_ACTIVE', 'selected' => $SMTP_ACTIVE, 'options' => $mail_transport_options]) ?>
65dd6b2bfcSGreg Roach            <p class="small text-muted">
661dcac87eSGreg Roach                <?= /* I18N: Help text for the “Messages” site configuration setting */
671dcac87eSGreg Roach                I18N::translate('webtrees needs to send emails, such as password reminders and website notifications.') ?>
68dd6b2bfcSGreg Roach            </p>
69dd6b2bfcSGreg Roach        </div>
70dd6b2bfcSGreg Roach    </div>
71dd6b2bfcSGreg Roach
72dd6b2bfcSGreg Roach    <div class="row form-group">
73dd6b2bfcSGreg Roach        <label for="SMTP_FROM_NAME" class="col-sm-3 col-form-label">
741dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
751dcac87eSGreg Roach            I18N::translate('Sender name') ?>
76dd6b2bfcSGreg Roach        </label>
77dd6b2bfcSGreg Roach        <div class="col-sm-9">
781dcac87eSGreg Roach            <input type="email" class="form-control" id="SMTP_FROM_NAME" name="SMTP_FROM_NAME" value="<?= e($SMTP_FROM_NAME) ?>" maxlength="255">
79dd6b2bfcSGreg Roach            <p class="small text-muted">
801dcac87eSGreg Roach                <?= /* I18N: Help text for the “Sender name” site configuration setting */
811dcac87eSGreg Roach                I18N::translate('This name is used in the “From” field, when sending automatic emails from this server.') ?>
82dd6b2bfcSGreg Roach            </p>
831dcac87eSGreg Roach
841dcac87eSGreg Roach            <?php if (!$smtp_from_name_valid) : ?>
851dcac87eSGreg Roach                <p class="alert alert-warning">
861dcac87eSGreg Roach                    <?= I18N::translate('Most mail servers require a valid email address.') ?>
871dcac87eSGreg Roach                </p>
881dcac87eSGreg Roach            <?php endif ?>
89dd6b2bfcSGreg Roach        </div>
90dd6b2bfcSGreg Roach    </div>
91dd6b2bfcSGreg Roach
92dd6b2bfcSGreg Roach    <h2><?= I18N::translate('SMTP mail server') ?></h2>
93dd6b2bfcSGreg Roach
94dd6b2bfcSGreg Roach    <div class="row form-group">
95dd6b2bfcSGreg Roach        <label for="SMTP_HOST" class="col-sm-3 col-form-label">
961dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
971dcac87eSGreg Roach            I18N::translate('Server name') ?>
98dd6b2bfcSGreg Roach        </label>
99dd6b2bfcSGreg Roach        <div class="col-sm-9">
1001dcac87eSGreg 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-]+)*">
101dd6b2bfcSGreg Roach            <p class="small text-muted">
1021dcac87eSGreg Roach                <?= /* I18N: Help text for the “Server name” site configuration setting */
1031dcac87eSGreg 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.') ?>
104dd6b2bfcSGreg Roach            </p>
105dd6b2bfcSGreg Roach        </div>
106dd6b2bfcSGreg Roach    </div>
107dd6b2bfcSGreg Roach
108dd6b2bfcSGreg Roach    <div class="row form-group">
109dd6b2bfcSGreg Roach        <label for="SMTP_PORT" class="col-sm-3 col-form-label">
1101dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1111dcac87eSGreg Roach            I18N::translate('Port number') ?>
112dd6b2bfcSGreg Roach        </label>
113dd6b2bfcSGreg Roach        <div class="col-sm-9">
1141dcac87eSGreg Roach            <input type="text" class="form-control" id="SMTP_PORT" name="SMTP_PORT" value="<?= e($SMTP_PORT) ?>" pattern="[0-9]*" placeholder="25" maxlength="5">
115dd6b2bfcSGreg Roach            <p class="small text-muted">
1161dcac87eSGreg Roach                <?= /* I18N: Help text for the "Port number" site configuration setting */
1171dcac87eSGreg Roach                I18N::translate('By default, SMTP works on port 25.') ?>
118dd6b2bfcSGreg Roach            </p>
119dd6b2bfcSGreg Roach        </div>
120dd6b2bfcSGreg Roach    </div>
121dd6b2bfcSGreg Roach
122dd6b2bfcSGreg Roach    <fieldset class="form-group">
123dd6b2bfcSGreg Roach        <div class="row">
124dd6b2bfcSGreg Roach            <legend class="col-form-label col-sm-3">
1251dcac87eSGreg Roach                <?= /* I18N: A configuration setting */
1261dcac87eSGreg Roach                I18N::translate('Use password') ?>
127dd6b2bfcSGreg Roach            </legend>
128dd6b2bfcSGreg Roach            <div class="col-sm-9">
1291dcac87eSGreg Roach                <?= view('components/radios-inline', ['name' => 'SMTP_AUTH', 'options' => [I18N::translate('no'), I18N::translate('yes')], 'selected' => (int) $SMTP_AUTH]) ?>
130dd6b2bfcSGreg Roach                <p class="small text-muted">
1311dcac87eSGreg Roach                    <?= /* I18N: Help text for the “Use password” site configuration setting */
1321dcac87eSGreg Roach                    I18N::translate('Most SMTP servers require a password.') ?>
133dd6b2bfcSGreg Roach                </p>
134dd6b2bfcSGreg Roach            </div>
135dd6b2bfcSGreg Roach        </div>
136dd6b2bfcSGreg Roach    </fieldset>
137dd6b2bfcSGreg Roach
138dd6b2bfcSGreg Roach    <div class="row form-group">
139dd6b2bfcSGreg Roach        <label for="SMTP_AUTH_USER" class="col-sm-3 col-form-label">
1401dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1411dcac87eSGreg Roach            I18N::translate('Username') ?>
142dd6b2bfcSGreg Roach        </label>
143dd6b2bfcSGreg Roach        <div class="col-sm-9">
1441dcac87eSGreg Roach            <input type="text" class="form-control" id="SMTP_AUTH_USER" name="SMTP_AUTH_USER" value="<?= e($SMTP_AUTH_USER) ?>" maxlength="255">
145dd6b2bfcSGreg Roach            <p class="small text-muted">
1461dcac87eSGreg Roach                <?= /* I18N: Help text for the "Username" site configuration setting */
1471dcac87eSGreg Roach                I18N::translate('The username required for authentication with the SMTP server.') ?>
148dd6b2bfcSGreg Roach            </p>
149dd6b2bfcSGreg Roach        </div>
150dd6b2bfcSGreg Roach    </div>
151dd6b2bfcSGreg Roach
152dd6b2bfcSGreg Roach    <div class="row form-group">
153dd6b2bfcSGreg Roach        <label for="SMTP_AUTH_PASS" class="col-sm-3 col-form-label">
1541dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1551dcac87eSGreg Roach            I18N::translate('Password') ?>
156dd6b2bfcSGreg Roach        </label>
157dd6b2bfcSGreg Roach        <div class="col-sm-9">
1581f1ffa65SGreg Roach            <input type="password" class="form-control" id="SMTP_AUTH_PASS" name="SMTP_AUTH_PASS" value="" autocomplete="off">
159dd6b2bfcSGreg Roach            <p class="small text-muted">
1601dcac87eSGreg Roach                <?= /* I18N: Help text for the "Password" site configuration setting */
1611dcac87eSGreg Roach                I18N::translate('The password required for authentication with the SMTP server.') ?>
162dd6b2bfcSGreg Roach            </p>
163dd6b2bfcSGreg Roach        </div>
164dd6b2bfcSGreg Roach    </div>
165dd6b2bfcSGreg Roach
166dd6b2bfcSGreg Roach    <div class="row form-group">
167dd6b2bfcSGreg Roach        <label for="SMTP_SSL" class="col-sm-3 col-form-label">
1681dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1691dcac87eSGreg Roach            I18N::translate('Secure connection') ?>
170dd6b2bfcSGreg Roach        </label>
171dd6b2bfcSGreg Roach        <div class="col-sm-9">
1721dcac87eSGreg Roach            <?= view('components/select', ['name' => 'SMTP_SSL', 'selected' => $SMTP_SSL, 'options' => $mail_ssl_options]) ?>
173dd6b2bfcSGreg Roach            <p class="small text-muted">
1741dcac87eSGreg Roach                <?= /* I18N: Help text for the “Secure connection” site configuration setting */
1751dcac87eSGreg Roach                I18N::translate('Most servers do not use secure connections.') ?>
176dd6b2bfcSGreg Roach            </p>
177dd6b2bfcSGreg Roach        </div>
178dd6b2bfcSGreg Roach    </div>
179dd6b2bfcSGreg Roach
180dd6b2bfcSGreg Roach    <div class="row form-group">
181dd6b2bfcSGreg Roach        <label for="SMTP_HELO" class="col-sm-3 col-form-label">
1821dcac87eSGreg Roach            <?= /* I18N: A configuration setting */
1831dcac87eSGreg Roach            I18N::translate('Sending server name') ?>
184dd6b2bfcSGreg Roach        </label>
185dd6b2bfcSGreg Roach        <div class="col-sm-9">
1861dcac87eSGreg 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-]+)*">
187dd6b2bfcSGreg Roach            <p class="small text-muted">
1881dcac87eSGreg Roach                <?= /* I18N: Help text for the "Sending server name" site configuration setting */
1891dcac87eSGreg Roach                I18N::translate('Most mail servers require that the sending server identifies itself correctly, using a valid domain name.') ?>
190dd6b2bfcSGreg Roach            </p>
1911dcac87eSGreg Roach
1921dcac87eSGreg Roach            <?php if (!$smtp_helo_valid) : ?>
1931dcac87eSGreg Roach                <p class="alert alert-warning">
1941dcac87eSGreg Roach                    <?= I18N::translate('Most mail servers require a valid domain name.') ?>
1951dcac87eSGreg Roach                </p>
1961dcac87eSGreg Roach            <?php endif ?>
197dd6b2bfcSGreg Roach        </div>
198dd6b2bfcSGreg Roach    </div>
199dd6b2bfcSGreg Roach
2004d99955eSGreg Roach    <h2>
2011dcac87eSGreg Roach        <?= /* I18N: https://en.wikipedia.org/wiki/DomainKeys_Identified_Mail */
2021dcac87eSGreg Roach        I18N::translate('DKIM digital signature') ?>
2034d99955eSGreg Roach    </h2>
2044d99955eSGreg Roach
2054d99955eSGreg Roach    <div class="row form-group">
2064d99955eSGreg Roach        <label for="DKIM_DOMAIN" class="col-sm-3 col-form-label">
2074d99955eSGreg Roach            <?= I18N::translate('Domain name') ?>
2084d99955eSGreg Roach        </label>
2094d99955eSGreg Roach        <div class="col-sm-9">
2101dcac87eSGreg Roach            <input type="text" class="form-control" id="DKIM_DOMAIN" name="DKIM_DOMAIN" value="<?= e($DKIM_DOMAIN) ?>" maxlength="255">
2114d99955eSGreg Roach        </div>
2124d99955eSGreg Roach    </div>
2134d99955eSGreg Roach
2144d99955eSGreg Roach    <div class="row form-group">
2154d99955eSGreg Roach        <label for="DKIM_SELECTOR" class="col-sm-3 col-form-label">
2164d99955eSGreg Roach            <?= I18N::translate('Selector') ?>
2174d99955eSGreg Roach        </label>
2184d99955eSGreg Roach        <div class="col-sm-9">
2191dcac87eSGreg Roach            <input type="text" class="form-control" id="DKIM_SELECTOR" name="DKIM_SELECTOR" value="<?= e($DKIM_SELECTOR) ?>" maxlength="255">
2204d99955eSGreg Roach        </div>
2214d99955eSGreg Roach    </div>
2224d99955eSGreg Roach
2234d99955eSGreg Roach    <div class="row form-group">
2244d99955eSGreg Roach        <label for="DKIM_KEY" class="col-sm-3 col-form-label">
2254d99955eSGreg Roach            <?= I18N::translate('Private key') ?>
2264d99955eSGreg Roach        </label>
2274d99955eSGreg Roach        <div class="col-sm-9">
2281dcac87eSGreg Roach            <textarea class="form-control" id="DKIM_KEY" name="DKIM_KEY"><?= e($DKIM_KEY) ?></textarea>
2294d99955eSGreg Roach        </div>
2304d99955eSGreg Roach    </div>
2314d99955eSGreg Roach
2321dcac87eSGreg Roach    <hr>
2331dcac87eSGreg Roach
234dd6b2bfcSGreg Roach    <div class="row form-group">
235dd6b2bfcSGreg Roach        <div class="offset-sm-3 col-sm-9">
236*b4144a6dSGreg Roach            <p class="form-check">
237*b4144a6dSGreg Roach                <input class="form-check-input" type="checkbox" id="test" name="test">
238*b4144a6dSGreg Roach                <label class="form-check-label" for="test">
239*b4144a6dSGreg Roach                    <?= I18N::translate('Send a test email using these settings') ?>
240*b4144a6dSGreg Roach                </label>
241*b4144a6dSGreg Roach            </p>
242*b4144a6dSGreg Roach
243dd6b2bfcSGreg Roach            <button type="submit" class="btn btn-primary">
244dd6b2bfcSGreg Roach                <?= view('icons/save') ?>
245dd6b2bfcSGreg Roach                <?= I18N::translate('save') ?>
246dd6b2bfcSGreg Roach            </button>
247dd6b2bfcSGreg Roach
2480c0910bfSGreg Roach            <a href="<?= e(route(ControlPanel::class)) ?>" class="btn btn-secondary">
249dd6b2bfcSGreg Roach                <?= view('icons/cancel') ?>
250dd6b2bfcSGreg Roach                <?= I18N::translate('cancel') ?>
251dd6b2bfcSGreg Roach            </a>
252dd6b2bfcSGreg Roach        </div>
253dd6b2bfcSGreg Roach    </div>
254dd6b2bfcSGreg Roach</form>
255510d3f2fSGreg Roach
256510d3f2fSGreg Roach<?php View::push('javascript') ?>
257510d3f2fSGreg Roach<script>
2581dcac87eSGreg Roach    $("#SMTP_AUTH_PASS").hideShowPassword("infer", true);
259510d3f2fSGreg Roach</script>
260510d3f2fSGreg Roach<?php View::endpush() ?>
261