Skip to content

Commit 9347c2a

Browse files
committed
Sending mail credentials to email [edit form]
1 parent 930a2a8 commit 9347c2a

File tree

4 files changed

+57
-1
lines changed

4 files changed

+57
-1
lines changed

web/edit/mail/index.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,17 @@
179179
exit();
180180
}
181181

182+
// Validate email
183+
if ((!empty($_POST['v_send_email'])) && (empty($_SESSION['error_msg']))) {
184+
if (!filter_var($_POST['v_send_email'], FILTER_VALIDATE_EMAIL)) {
185+
$_SESSION['error_msg'] = __('Please enter valid email address.');
186+
}
187+
}
188+
182189
$v_domain = escapeshellarg($_POST['v_domain']);
183190
$v_account = escapeshellarg($_POST['v_account']);
191+
$v_send_email = $_POST['v_send_email'];
192+
$v_credentials = $_POST['v_credentials'];
184193

185194
// Change password
186195
if ((!empty($_POST['v_password'])) && (empty($_SESSION['error_msg']))) {
@@ -297,6 +306,16 @@
297306
}
298307
}
299308

309+
// Email login credentials
310+
if ((!empty($v_send_email)) && (empty($_SESSION['error_msg']))) {
311+
$to = $v_send_email;
312+
$subject = __("Email Credentials");
313+
$hostname = exec('hostname');
314+
$from = __('MAIL_FROM', $hostname);
315+
$mailtext = $v_credentials;
316+
send_email($to, $subject, $mailtext, $from);
317+
}
318+
300319
// Set success message
301320
if (empty($_SESSION['error_msg'])) {
302321
$_SESSION['ok_msg'] = __('Changes has been saved.');

web/inc/main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
session_start();
44

55
define('VESTA_CMD', '/usr/bin/sudo /usr/local/vesta/bin/');
6-
define('JS_LATEST_UPDATE', '1491697866');
6+
define('JS_LATEST_UPDATE', '1491697867');
77

88
$i = 0;
99

web/js/pages/edit_mail_acc.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,28 +91,53 @@ randomString = function() {
9191
$('#v_password').text(randomstring);
9292
else
9393
$('#v_password').text(Array(randomstring.length+1).join('*'));
94+
generate_mail_credentials();
95+
}
96+
97+
generate_mail_credentials = function() {
98+
var div = $('.mail-infoblock').clone();
99+
div.find('#mail_configuration').remove();
100+
var pass=div.find('#v_password').text();
101+
if (pass=="") div.find('#v_password').html(' ');
102+
var output = div.text();
103+
output=output.replace(/(?:\r\n|\r|\n|\t)/g, "|");
104+
output=output.replace(/ /g, "");
105+
output=output.replace(/\|\|/g, "|");
106+
output=output.replace(/\|\|/g, "|");
107+
output=output.replace(/\|\|/g, "|");
108+
output=output.replace(/^\|+/g, "");
109+
output=output.replace(/\|$/, "");
110+
output=output.replace(/ $/, "");
111+
output=output.replace(/:\|/g, ": ");
112+
output=output.replace(/\|/g, "\n");
113+
//console.log(output);
114+
$('#v_credentials').val(output);
94115
}
95116

96117
$(document).ready(function() {
97118
$('#v_account').text($('input[name=v_account]').val());
98119
$('#v_password').text($('input[name=v_password]').val());
120+
generate_mail_credentials();
99121

100122
$('input[name=v_account]').change(function(){
101123
$('#v_account').text($(this).val());
124+
generate_mail_credentials();
102125
});
103126

104127
$('input[name=v_password]').change(function(){
105128
if($('input[name=v_password]').attr('type') == 'text')
106129
$('#v_password').text($(this).val());
107130
else
108131
$('#v_password').text(Array($(this).val().length+1).join('*'));
132+
generate_mail_credentials();
109133
});
110134

111135
$('.toggle-psw-visibility-icon').click(function(){
112136
if($('input[name=v_password]').attr('type') == 'text')
113137
$('#v_password').text($('input[name=v_password]').val());
114138
else
115139
$('#v_password').text(Array($('input[name=v_password]').val().length+1).join('*'));
140+
generate_mail_credentials();
116141
});
117142

118143
$('#mail_configuration').change(function(evt){
@@ -145,5 +170,6 @@ $(document).ready(function() {
145170
$('#td_smtp_encryption').html(opt.attr('no_encryption'));
146171
break;
147172
}
173+
generate_mail_credentials();
148174
});
149175
});

web/templates/admin/edit_mail_acc.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@
125125
</table>
126126
</td>
127127
</tr>
128+
<tr>
129+
<td class="vst-text input-label">
130+
<?php print __('Send login credentials to email address') ?>
131+
</td>
132+
</tr>
133+
<tr>
134+
<td>
135+
<input type="text" class="vst-input" name="v_send_email" value="<?=htmlentities(trim($v_send_email, "'"))?>">
136+
<input type="hidden" name="v_credentials" id="v_credentials">
137+
</td>
138+
</tr>
128139
</table>
129140
<table class="data-col2">
130141
<tr>

0 commit comments

Comments
 (0)