1package Swatchdog::SendMail;
2require 5.000;
3require Exporter;
4
5use strict;
6use Carp;
7use Mail::Sendmail;
8use Sys::Hostname;
9
10use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
11
12@ISA = qw(Exporter);
13@EXPORT = qw/
14  &send_mail
15/;
16$VERSION = '20031118';
17
18################################################################
19
20sub send_mail {
21  my $login = (getpwuid($<))[0];
22  my $host = hostname;
23  my %opts = (
24              'ADDRESSES' => $login,
25              'FROM' => "$login\@$host",
26              'SUBJECT' => 'Message from Swatchdog',
27	      @_
28  );
29
30  (my $to_line = $opts{'ADDRESSES'}) =~ s/:/,/g;
31
32  my %mail = ( To => $to_line,
33               From => $opts{FROM},,
34	       Subject => $opts{SUBJECT},
35	       Message => $opts{MESSAGE},
36  );
37  sendmail(%mail) or warn $Mail::Sendmail::error;
38  return 0;
39}
40
41################################################################
42## The POD ###
43
44=head1 NAME
45
46  Swatchdog::SendMail - Swatchdog interface to the Mail::Sendmail module
47
48=head1 SYNOPSIS
49
50  use Swatchdog::SendMail;
51
52=head1 SWATCH SYNTAX
53
54=head1 DESCRIPTION
55
56=head1 AUTHOR
57
58E. Todd Atkins, todd.atkins@stanfordalumni.org
59
60=head1 SEE ALSO
61
62perl(1), swatchdog(1).
63
64=cut
65
661;
67