--- /dev/null
+structure Pass :> PASS =
+struct
+
+fun validEmail email =
+ case String.fields (fn ch => ch = #"@") email of
+ [_, dom] => dom <> "localhost"
+ | _ => false
+
+val vmp = "/usr/local/bin/vmailpasswd"
+
+fun change (email, old, new) =
+ let
+ val cmd = String.concat ["/usr/local/bin/vmailpasswd \"",
+ String.toString email,
+ "\" \"",
+ String.toString old,
+ "\" \"",
+ String.toString new,
+ "\" >/dev/null 2>/dev/null"]
+ in
+ OS.Process.isSuccess (OS.Process.system cmd)
+ end
+
+end
--- /dev/null
+<html><head>
+<title>Change virtual mailbox password</title>
+</head><body>
+
+<% if $"email" <> "" then
+ val email = $"email"
+ val old = $"old"
+ val new = $"new"
+ val new2 = $"new2"
+
+ if not (Pass.validEmail email) then
+ %><h2><b>That is not a valid virtual mailbox address!</b></h2><%
+ elseif new <> new2 then
+ %><h2><b>Your new passwords do not match.</b></h2><%
+ elseif not (Pass.change (email, old, new)) then
+ %><h2><b>Error changing password. Did you enter the right e-mail address and current password?</b></h2><%
+ else
+ %><h2><b>Password changed!</b></h2><%
+ end
+end %>
+
+<h2><b>Change virtual mailbox password</b></h2>
+
+<form action="passwd" method="post">
+
+<table>
+<tr> <td align="right"><b>E-mail address</b>:</td> <td><input name="email" value="<% Web.html ($"email") %>"></td> </tr>
+<tr> <td align="right"><b>Old password</b>:</td> <td><input type="password" name="old"></td> </tr>
+<tr> <td align="right"><b>New password</b>:</td> <td><input type="password" name="new"></td> </tr>
+<tr> <td align="right"><b>Confirm new password</b>:</td> <td><input type="password" name="new2"></td> </tr>
+<tr> <td><input type="submit" value="Change"></td> </tr>
+</table>
+
+</form>
+
+</body></html>
\ No newline at end of file