A few things need to be done, its not as clean as I'd like but hey it works
Create a rule, select 'subject' contains 'NEW ACCOUNT CREATED' & set 'Action' to 'Run Function', Script Function 'ACCOUNT'
You will need to change these values in signup.php, this relies on you having a mysql/mariadb install in order to check if the account already exists
domain1.tld/domain2.tld -> your domains
C:\path\to\newacc.vbs ->wherever youre placing the newacc.vbs file
dbaddress/username/password -> to your mysql/mariadb credentials
email@address.com -> change to your postmaster/webmaster email address
signup.php
Code: Select all
<!DOCTYPE HTML>
<html>
<head>
<style>
p {
color: red;
font-family: verdana;
font-size: 80%;
}
form {
border: 8px solid black;
margin: auto;
width: 200px;
top: 50px;
left: 50%;
}
.submit {
position: relative;
margin-left: 35%;
}
.domain {
position: center;
margin-left: 22%;
}
.email {
position: center;
margin-left: 5%;
}
div {text-align: center;}
p {text-align: center;}
</style>
</head>
<title>E-mail Signup form</title>
<script>
if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}
</script>
<body style="background-color:#432938;" >
<form name="form" class="form" method="POST" action="./form.php">
<p><label for="domain">Choose domain:</label></p>
<select required="required" name="domain" class="domain" id="domain" required>
<option value="domain1.tld">domain1.tld</option>
<option value="domain2.tld">domain2.tld</option>
</select>
<p class="Username">Username:</p>
<input name="email" required="required" class="email" type="text" id="email" title="email" pattern="^[a-zA-Z0-9]+$" /><br>
<p>Password:</p>
<input name="password" minlength="8" class="email" required="required" type="password" id="password" />
<p>Confirm Password:</p>
<input name="password_confirm" class="email" required="required" type="password" id="password_confirm" oninput="check(this)" />
<script language='javascript' type='text/javascript'>
function check(input) {
if (input.value != document.getElementById('password').value) {
input.setCustomValidity('Password Must be Matching.');
} else {
input.setCustomValidity('');
}
}
</script>
<br /><br />
<input type="submit" class="submit" name="registerBtn">
</form>
</body>
</html>
<?php
if (isset($_POST['registerBtn'])){
$acc = $_POST['email'];
$pass = $_POST['password'];
$domain = $_POST['domain'];
if (empty($acc)) {
echo '<div>No account entered</div>';
exit;
}
if (empty($pass)) {
echo '<div>Password is empty</div>';
exit;
}
$path_to_file = 'C:\path\to\newacc.vbs';
$path_to_newfile = 'C:\Windows\temp\run.vbs';
$file_contents = file_get_contents($path_to_file);
$file_contents = str_replace('aco', $acc, $file_contents);
$file_contents = str_replace("newpass", $pass, $file_contents);
$file_contents = str_replace("domain.com", $domain, $file_contents);
file_put_contents($path_to_newfile, $file_contents);
$mysqli = new mysqli("dbaddress", "username", "password", "mail");
$result = $mysqli->query("SELECT * FROM `hm_accounts`WHERE accountaddress = '$acc@$domain';");
if($result->num_rows == 0) {
} else {
echo "<div><strong style=color:red;>Account taken!</strong></div>";
exit;
}
$mysqli->close();
$success = mail("email@address.com","NEW ACCOUNT CREATED","NEW ACCOUNT $acc@$domain",'Content-Type: text/plain;charset=utf-8');
if (!$success) {
print_r(error_get_last()['message']);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
// Send email code
die('<div><strong>Account created! <a href="/Home/">Return to Home?</a><br>Login <a href="https://mail.domain.tld">here</a></div></strong>');
}
}
?>
newacc.vbs
Code: Select all
Dim obApp
Set obApp = CreateObject("hMailServer.Application")
Call obApp.Authenticate("Administrator", "your_hmail_password")
Dim obDomain
Set obDomain = obApp.Domains.ItemByName("domain.com")
Dim obAccount
Set obAccount = obDomain.Accounts.Add
obAccount.Address = "aco@domain.com"
obAccount.Password = "newpass"
obAccount.Active = False
obAccount.MaxSize = 0
obAccount.Save
obAccount.IMAPFolders.add("Sent")
obAccount.IMAPFolders.add("Drafts")
obAccount.IMAPFolders.add("Spam")
obAccount.IMAPFolders.add("Archive")
obAccount.IMAPFolders.add("Trash")
Set oFso = CreateObject("Scripting.FileSystemObject") : oFso.DeleteFile Wscript.ScriptFullName, True
Code: Select all
Sub ACCOUNT(oMessage)
With CreateObject("WScript.Shell")
.Run "C:\Windows\temp\run.vbs", 0, True
EventLog.Write("ACCOUNT Script")
End With
End Sub