3 # modified from pager.pm in flooterbuck changes are:
5 # Copyright (c) 2004 Tim Riker <Tim@Rikers.org>
7 # This package is free software; you can redistribute it and/or
8 # modify it under the terms of the license found in the file
9 # named LICENSE that should have accompanied this file.
11 # THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
12 # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
13 # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 use Mail::Mailer qw(sendmail);
31 # TODO only allow registered users?
34 &::status('page module requires Mail::Mailer.');
35 return 'page module not active';
38 unless ( $message =~ /^(\S+)\s+(.*)$/ ) {
46 # allow optional trailing : ie: page foo[:] hello
49 my $tofactoid = &::getFactoid( lc "${to}'s pager" );
50 if ( $tofactoid =~ /(\S+@\S+)/ ) {
52 $toaddr =~ s/^mailto://;
54 # TODO require sender-locked factoid?
56 my $fromfactoid = &::getFactoid( lc "${from}'s pager" );
59 if ( $fromfactoid =~ /(\S+@\S+)/ ) {
61 $fromaddr =~ s/^mailto://;
65 # TODO require sender to have valid self-locked pager factoid?
66 $fromaddr = 'infobot@example.com';
69 my $channel = $::chan || 'infobot';
71 # TODO disallow use from private message? $chan='_default'
74 "pager: from $from <$fromaddr>, to $to <$toaddr>, msg \"$msg\"");
76 To => "$to <$toaddr>",
77 From => "$from <$fromaddr>",
78 Subject => "Message from $channel!",
79 'X-Mailer' => 'infobot',
83 # for (keys %headers) {
84 # $logmsg .= "$_: $headers{$_}\n";
86 # $logmsg .= "\n$msg\n";
87 # &::status("pager:\n$logmsg");
90 my $mailer = new Mail::Mailer 'sendmail';
91 $failed++ unless $mailer->open( \%headers );
92 $failed++ unless print $mailer "$msg\n";
93 $failed++ unless $mailer->close;
96 $retval = 'Sorry, an error occurred while sending mail.';
99 $retval = "$from: I sent mail to $toaddr from $fromaddr.";
103 $retval = "Sorry, I don't know ${to}'s email address.";
105 &::performStrictReply($retval);
110 # vim:ts=4:sw=4:expandtab:tw=80