If you're using Dovecot for mail retrieval and you want to generate SHA1 passwords yourself, you'll need to set the raw_output value to true, then base64_encode the output:
<?php
function makeDovecotPassword($input)
{
return '{SHA}' . base64_encode(sha1($input, true));
}
?>