Skip to content

Commit f4f87e6

Browse files
committed
added email notifcation
1 parent a6c992c commit f4f87e6

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

bin/v_add_user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if [ ! -z "$fname" ]; then
4747
fi
4848

4949
is_user_free "$user"
50-
is_package_valid "$package"
50+
is_package_valid
5151

5252

5353
#----------------------------------------------------------#

web/add/user/index.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
$v_email = escapeshellarg($_POST['v_email']);
3535
$v_fname = escapeshellarg($_POST['v_fname']);
3636
$v_lname = escapeshellarg($_POST['v_lname']);
37+
if (empty($_POST['v_notify'])) $v_notify = 'off';
3738

3839
// Check for errors
3940
if (!empty($errors[0])) {
@@ -52,6 +53,24 @@
5253
if (empty($error)) $error = 'Error: vesta did not return any output.';
5354
$_SESSION['error_msg'] = $error;
5455
} else {
56+
if (empty($v_notify)) {
57+
$to = $_POST['v_email'];
58+
$subject = "Welcome to Vesta Control Panel";
59+
$hostname = exec('hostname');
60+
$from = "Vesta Control Panel <noreply@".$hostname.">";
61+
if (!empty($_POST['v_fname'])) {
62+
$mailtext = "Hello ".$_POST['v_fname']." ".$_POST['v_lname'].",\n";
63+
} else {
64+
$mailtext = "Hello,\n";
65+
}
66+
$mailtext .= "Your account has been created successfully and is ready to use.\n\n";
67+
$mailtext .= "https://".$_SERVER['HTTP_HOST']."/login/\n";
68+
$mailtext .= "username: ".$_POST['v_username']."\n";
69+
$mailtext .= "password: ".$_POST['v_password']."\n\n";
70+
$mailtext .= "Have a nice day,\nThe VestaCP Team\n";
71+
send_email($to, $subject, $mailtext, $from);
72+
}
73+
5574
$_SESSION['ok_msg'] = "OK: user <b>".$_POST[v_username]."</b> has been created successfully.";
5675
unset($v_username);
5776
unset($v_password);
@@ -63,7 +82,6 @@
6382
}
6483
}
6584

66-
6785
exec (VESTA_CMD."v_list_user_packages json", $output, $return_var);
6886
check_error($return_var);
6987
$data = json_decode(implode('', $output), true);

web/templates/admin/add_user.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
<tr><td><input type="text" size="20" class="add-input" name="v_fname" <?php if (!empty($v_fname)) echo "value=".$v_fname; ?>></tr>
4848
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Last Name</td></tr>
4949
<tr><td><input type="text" size="20" class="add-input" name="v_lname" <?php if (!empty($v_lname)) echo "value=".$v_lname; ?>></tr>
50+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Send login credentials to the user's email address</td></tr>
51+
<tr><td><input type="checkbox" size="20" class="add-checkbox" name="v_notify" <?php if (empty($v_notify)) echo "checked=yes"; ?>></tr>
5052
<tr><td style="padding: 24px 0 0 0;">
5153
<input type="submit" name="ok" value="OK" class="add-button">
5254
</form>

0 commit comments

Comments
 (0)