I tried in PHP via SSH to generate password with the command dovecotpw
and if the password contains the $ sign symbol than it generates different hash from the hash the dovecotpw generates in command line.
here is the line that generates the password:
echo $ssh->exec('dovecotpw -s CRAM-MD5 -p test$test');
The remote shell is using the $
to denote a shell variable. Escape the argument.
...('... \'test$test\'');