- let
- val proc = Unix.execute ("/bin/sh", ["-c",
- String.concat [Config.Courier.userdbpw, " | ", Config.Courier.userdb,
- " \"", domain, "/", user, "@", domain, "\" set systempw"]])
- val outf = Unix.textOutstreamOf proc
- in
- TextIO.output (outf, String.concat [passwd, "\n", passwd, "\n"]);
- TextIO.closeOut outf;
- if not (OS.Process.isSuccess (Unix.reap proc)) then
- SOME "Error setting password"
- else if not (rebuild ()) then
- SOME "Error reloading userdb"
- else
- NONE
- end
+ if not (mailboxExists {domain = domain, user = user}) then
+ SOME "Mailbox doesn't exist"
+ else let
+ val proc = Unix.execute ("/bin/sh", ["-c",
+ String.concat [Config.Courier.userdbpw, " | ", Config.Courier.userdb,
+ " \"", domain, "/", user, "@", domain, "\" set systempw"]])
+ val outf = Unix.textOutstreamOf proc
+ in
+ TextIO.output (outf, String.concat [passwd, "\n", passwd, "\n"]);
+ TextIO.closeOut outf;
+ if not (OS.Process.isSuccess (Unix.reap proc)) then
+ SOME "Error setting password"
+ else if not (rebuild ()) then
+ SOME "Error reloading userdb"
+ else
+ NONE
+ end