#!/usr/bin/perl # TmNetWiki version 0.4 (September 11, 2002) # Copyright (C) 2002 Adam Brate # # Based on the GPLed UseModWiki 0.92 # Copyright (C) 2000-2001 Clifford A. Adams # or # Based on the GPLed AtisWiki 0.3 (C) 1998 Markus Denker # # ...which was based on # the LGPLed CVWiki CVS-patches (C) 1997 Peter Merel # and The Original WikiWikiWeb (C) Ward Cunningham # (code reused with permission) # Email and ThinLine options by Jim Mahoney # # 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 # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the # Free Software Foundation, Inc. # 59 Temple Place, Suite 330 # Boston, MA 02111-1307 USA package Wiki::email; use strict; # needs subs # needs consts $SendMail, $EmailNotify, $DataDir, $SiteName # needs vars $q, %Page use base 'Exporter'; use Wiki::consts; @EXPORT = qw(EmailNotify); sub SendEmail; # Translation note: the email messages are still sent in English # Send an email message. sub SendEmail { my ($to, $from, $reply, $subject, $message) = @_; ### debug ## print "Content-type: text/plain\n\n"; ## print " to: '$to'\n"; ## return; # sendmail options: # -odq : send mail to queue (i.e. later when convenient) # -oi : do not wait for "." line to exit # -t : headers determine recipient. open (SENDMAIL, "| $SendMail -oi -t ") or die "Can't send email: $!\n"; print SENDMAIL <<"EOF"; From: $from To: $to Reply-to: $reply Subject: $subject\n $message EOF close(SENDMAIL) or warn "sendmail didn't close nicely"; } ## Email folks who want to know a note that a page has been modified. - JimM. sub EmailNotify { local $/ = "\n"; # don't slurp whole files in this sub. if ($EmailNotify) { my ($id, $user) = @_; if ($user) { $user = " by $user"; } my $address; open(EMAIL, "$DataDir/emails") or die "Can't open $DataDir/emails: $!\n"; $address = join ",", ; $address =~ s/\n//g; close(EMAIL); my $home_url = $q->url(); my $page_url = $home_url . "?$id"; my $editors_summary = $q->param("summary"); if (($editors_summary eq "*") or ($editors_summary eq "")){ $editors_summary = ""; } else { $editors_summary = "\n Summary: $editors_summary"; } my $content = <<"END_MAIL_CONTENT"; The $SiteName page $id at $page_url has been changed$user to revision $Page{revision}. $editors_summary (Replying to this notification will send email to the entire mailing list, so only do that if you mean to. To remove yourself from this list, visit ${home_url}?action=editprefs .) END_MAIL_CONTENT my $subject = "The $id page at $SiteName has been changed."; # I'm setting the "reply-to" field to be the same as the "to:" field # which seems appropriate for a mailing list, especially since the # $EmailFrom string needn't be a real email address. &SendEmail($address, $EmailFrom, $address, $subject, $content); } }