(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: invite_user.ml,v 1.7 2006/03/28 13:20:00 rich Exp $
+ * $Id: invite_user.ml,v 1.10 2006/12/06 09:46:57 rich Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
let emails = Pcre.split ~rex:split_re emails in
(* This guy's got no friends ... *)
- if emails = [] then (
+ if emails = [] then
q#redirect ("http://" ^ hostname ^ "/");
- return ()
- );
let userid, username, email = match user with
User (userid, username, _, prefs) -> userid, username, prefs.email
let subject = username ^ " has invited you to join " ^ hostname in
(* Get a suitable return address for the email. *)
- let from =
+ let from_addr =
match email with
- | Some email -> email
- | None -> "service@merjis.com" in
+ | Some email -> username, email
+ | None -> username, "service@merjis.com" in
(* Add user accounts for these new users. For users who are already
* registered, we'll send reminder emails.
| _ -> assert false in
(* Send the email. *)
- Sendmail.send_mail ~subject ~to_addr:[email] ~from body
+ let to_addrs = [ "", email ] in
+ let content_type =
+ "text/plain", ["charset", Mimestring.mk_param "UTF-8"] in
+
+ let msg =
+ Netsendmail.compose ~subject
+ ~to_addrs ~from_addr ~content_type body in
+ Netsendmail.sendmail msg
) emails;
(* Finish off. *)
let buttons = [ ok_button "/_users" ] in
ok ~buttons ~title:"Invitation emails sent"
- dbh hostid q "We sent invitations emails to those address(es)."
+ r dbh hostid q "We sent invitations emails to those address(es)."
let () =
register_script ~restrict:[CanManageUsers] ~anonymous:false run