Change subject line so it shows the name of the site.
authorrich <rich>
Sat, 8 Apr 2006 14:46:24 +0000 (14:46 +0000)
committerrich <rich>
Sat, 8 Apr 2006 14:46:24 +0000 (14:46 +0000)
Add an message which shows how to unsubscribe from messages.

scripts/lib/cocanwiki_emailnotify.ml

index c63b846..3214460 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_emailnotify.ml,v 1.7 2006/03/27 16:43:44 rich Exp $
+ * $Id: cocanwiki_emailnotify.ml,v 1.8 2006/04/08 14:46:24 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
@@ -62,6 +62,12 @@ let email_notify ~subject ~body ?user dbh hostid =
     | (name, None) -> None
   ) rows in
 
+  (* Get the canonical hostname. *)
+  let canonical_hostname = List.hd (
+    PGSQL(dbh)
+      "select canonical_hostname from hosts where id = $hostid"
+  ) in
+
   if to_addr <> [] then (
     (* Prepare the body of the message.  The assumption is that
      * this takes time and database access, so we defer the creation
@@ -69,7 +75,14 @@ let email_notify ~subject ~body ?user dbh hostid =
      *)
     let body = body () in
 
-    let subject = "Site notice: " ^ subject in
+    (* Add the opt-out signature to the body. *)
+    let body = body ^ "\n\n-- \n" ^
+      "To stop receiving further emails:\n" ^
+      "(1) Go to http://" ^ canonical_hostname ^ "/_userprefs\n" ^
+      "(2) Uncheck 'Receive email notifications'\n" ^
+      "(3) Press 'Update Preferences'\n" in
+
+    let subject = canonical_hostname ^ ": " ^ subject in
 
     (* Send the email. *)
     Sendmail.send_mail ~subject ~to_addr ?from body