Skip to content

Commit 4810eab

Browse files
authored
Merge pull request hestiacp#1559 from hestiacp/feature/1281-webmail-control
hestiacp#1281 Control webmail
2 parents b5d17e2 + ccf4e36 commit 4810eab

File tree

6 files changed

+40
-14
lines changed

6 files changed

+40
-14
lines changed

bin/v-add-letsencrypt-domain

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ check_hestia_demo_mode
120120
if [ ! -z "$mail" ]; then
121121
root_domain=$domain
122122
domain="mail.$root_domain"
123-
aliases="$WEBMAIL_ALIAS.$root_domain"
123+
webmail=$(get_object_value "mail" "$domain" '$WEBMAIL');
124+
if [ ! -z "$webmail" ]; then
125+
aliases="$WEBMAIL_ALIAS.$root_domain"
126+
fi
124127
fi
125128

126129
log_file="/var/log/hestia/LE-${user}-${domain}-$(date +%Y%m%d-%H%M%S).log"
@@ -243,7 +246,7 @@ fi
243246
for auth in $authz; do
244247
payload=''
245248
answer=$(query_le_v2 "$auth" "$payload" "$nonce")
246-
url=$(echo "$answer" |grep -A3 $proto |grep url |cut -f 4 -d \")
249+
url=$(echo "$answer" |grep -A3 $proto |grep -m1 url |cut -f 4 -d \")
247250
token=$(echo "$answer" |grep -A3 $proto |grep token |cut -f 4 -d \")
248251
nonce=$(echo "$answer" |grep -i nonce |cut -f2 -d \ |tr -d '\r\n')
249252
status=$(echo "$answer"|grep HTTP/ |tail -n1 |cut -f 2 -d ' ')

bin/v-add-mail-domain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fi
169169
# Add webmail configuration to mail domain
170170
if [ ! -z "$WEB_SYSTEM" ] || [ ! -z "$PROXY_SYSTEM" ]; then
171171
if [ ! -z "$IMAP_SYSTEM" ]; then
172-
$BIN/v-add-sys-webmail $user $domain '' ''
172+
$BIN/v-add-sys-webmail $user $domain '' '' ''
173173
fi
174174
fi
175175

web/add/mail/index.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,30 @@
8383
check_return_code($return_var,$output);
8484
unset($output);
8585
}
86-
87-
// Flush field values on success
88-
if (empty($_SESSION['error_msg'])) {
89-
$_SESSION['ok_msg'] = sprintf(_('MAIL_DOMAIN_CREATED_OK'),htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
90-
unset($v_domain);
91-
}
9286

9387
if (!empty($_SESSION['IMAP_SYSTEM']) && !empty($_SESSION['WEBMAIL_SYSTEM'])){
94-
if(!empty($_POST['v_webmail'])){
88+
if (empty($_SESSION['error_msg'])) {
89+
if (!empty($_POST['v_webmail'])) {
9590
$v_webmail = escapeshellarg($_POST['v_webmail']);
96-
exec (HESTIA_CMD."v-add-sys-webmail ".$user." ".$v_domain." ".$v_webmail, $output, $return_var);
91+
exec (HESTIA_CMD."v-add-sys-webmail ".$user." ".$v_domain." ".$v_webmail." yes", $output, $return_var);
9792
check_return_code($return_var,$output);
9893
unset($output);
9994
}
95+
}
96+
}
97+
98+
if (empty($_POST['v_webmail'])) {
99+
if (empty($_SESSION['error_msg'])) {
100+
exec (HESTIA_CMD."v-delete-sys-webmail ".$user." ".$v_domain." yes", $output, $return_var);
101+
check_return_code($return_var,$output);
102+
unset($output);
103+
}
104+
}
105+
106+
// Flush field values on success
107+
if (empty($_SESSION['error_msg'])) {
108+
$_SESSION['ok_msg'] = sprintf(_('MAIL_DOMAIN_CREATED_OK'),htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
109+
unset($v_domain, $v_webmail);
100110
}
101111
}
102112

web/edit/mail/index.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,25 @@
215215
check_return_code($return_var,$output);
216216
unset($output);
217217
}
218+
218219
if (!empty($_SESSION['IMAP_SYSTEM']) && !empty($_SESSION['WEBMAIL_SYSTEM'])){
219-
// Update webmail
220-
if ((!empty($_POST['v_webmail'])) && $_POST['v_webmail'] != $v_webmail && (empty($_SESSION['error_msg']))) {
220+
if (empty($_SESSION['error_msg'])) {
221+
if (!empty($_POST['v_webmail'])) {
221222
$v_webmail = escapeshellarg($_POST['v_webmail']);
222-
exec (HESTIA_CMD."v-add-sys-webmail ".$v_username." ".escapeshellarg($v_domain)." ".$v_webmail." yes", $output, $return_var);
223+
exec (HESTIA_CMD."v-add-sys-webmail ".$user." ".$v_domain." ".$v_webmail." yes", $output, $return_var);
223224
check_return_code($return_var,$output);
224225
unset($output);
225226
}
227+
}
228+
}
229+
230+
if (empty($_POST['v_webmail'])) {
231+
if (empty($_SESSION['error_msg'])) {
232+
exec (HESTIA_CMD."v-delete-sys-webmail ".$user." ".$v_domain." yes", $output, $return_var);
233+
check_return_code($return_var,$output);
234+
$v_webmail = "";
235+
unset($output);
236+
}
226237
}
227238

228239
// Change SSL certificate

web/templates/admin/add_mail.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
echo ">".htmlentities(ucfirst($client))."</option>\n";
7979
}
8080
?>
81+
<option value="" <?php if(empty($v_webmail)){ echo "selected";}?>><?php print _('Disabled');?></option>
8182
</select>
8283
</td>
8384
</tr>

web/templates/admin/edit_mail.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
echo ">".htmlentities(ucfirst($client))."</option>\n";
8282
}
8383
?>
84+
<option value="" <?php if (empty($v_webmail)){ echo "selected";}?>><?php print _('Disabled');?></option>
8485
</select>
8586
</td>
8687
</tr>

0 commit comments

Comments
 (0)