Search code examples
phpemailhashdovecot

Using php and doveadm to create password


I've created an registration page in php with an mysql backend. If the user is entering his new password it should become SHA512-CRYPT via doveadm.

This is what I have now,

$password=hash('sha256', $pass);

But I want to create a password hash with doveadm because of my mail server:

$password=(/usr/bin/doveadm pw -s SHA512-CRYPT -p "$pass")

But it doesn't seem to work, how can i implement this "doveadm" command in php?


Solution

  • You must call it with shell_exec method:

    $password = shell_exec('/usr/bin/doveadm pw -s SHA512-CRYPT -p '. $pass);