I've created an mail server with dovecot postfix and mysql.
The user should be able to create a new mail adress via a php webpage which will insert the data into the mysql database.
It also does insert it into the DB, but the connection to the mail server wont work with that credentials. 
When I insert the same things myself sirectly into the DB it works, can you please give that code a look and tell me what might be wrong?
I think it has something todo with the password hash generation with doveadm.
<?php
    ob_start();
    session_start();
    if( isset($_SESSION['user'])!="" ){
            header("Location: home.php");
    }
    include_once 'dbconnect.php';
    $error = false;
    if ( isset($_POST['btn-signup']) ) {
            // clean user inputs to prevent sql injections
            $name = trim($_POST['name']);
            $name = strip_tags($name);
            $name = htmlspecialchars($name);
            $email = trim($_POST['email']);
            $email = strip_tags($email);
            $email = htmlspecialchars($email);
            $pass = trim($_POST['pass']);
            $pass = strip_tags($pass);
            $pass = htmlspecialchars($pass);
            // basic name validation
            if (empty($name)) {
                    $error = true;
                    $nameError = "Please enter your full name.";
            } else if (strlen($name) < 3) {
                    $error = true;
                    $nameError = "Name must have atleat 3 characters.";
            } else {
                    // check email exist or not
                    $query = "SELECT username FROM accounts WHERE username='$name'";
                    $result = mysql_query($query);
                    $count = mysql_num_rows($result);
                    if($count!=0){
                            $error = true;
                            $nameError = "Benutzeraccount existiert schon.";
                    }
            }
            //basic email validation
            if ( !filter_var($email,FILTER_VALIDATE_EMAIL) ) {
                    $error = true;
                    $emailError = "Please enter valid email address.";
            } else {
                    // check email exist or not
                    $query = "SELECT resetmail FROM accounts WHERE resetmail='$email'";
                    $result = mysql_query($query);
                    $count = mysql_num_rows($result);
                    if($count!=0){
                            $error = true;
                            $emailError = "Kontakt E-Mail Adresse bereits in Verwendung.";
                    }
            }
            // password validation
            if (empty($pass)){
                    $error = true;
                    $passError = "Please enter password.";
            } else if(strlen($pass) < 6) {
                    $error = true;
                    $passError = "Password must have atleast 6 characters.";
            }
            // password encrypt using SHA256();
            $password = shell_exec('/usr/bin/doveadm pw -s SHA512-CRYPT -p '. $pass);
            // if there's no error, continue to signup
            if( !$error ) {
                    $query = "INSERT INTO accounts(username,domain,at,complete,resetmail,password,quota,enabled,sendonly) VALUES('$name','chillihorse.de','@','test','$email','$password','2048','1','0')";
                    $res = mysql_query($query);
                    if ($res) {
                            $errTyp = "success";
                            $errMSG = "Successfully registered, you may login now";
                            unset($name);
                            unset($email);
                            unset($pass);
                    } else {
                            $errTyp = "danger";
                            $errMSG = "Something went wrong, try again later...";
                    }
            }
    }
?>
 
    