PageRenderTime 22ms CodeModel.GetById 13ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/swatch-3.2.3/examples/SendMail.pm

#
Perl | 66 lines | 43 code | 20 blank | 3 comment | 0 complexity | fbb8291c64f87dc20e70dc515cd864c5 MD5 | raw file
 1package Swatch::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 Swatch',
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  Swatch::SendMail - Swatch interface to the Mail::Sendmail module
47
48=head1 SYNOPSIS
49
50  use Swatch::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), swatch(1).
63
64=cut
65  
661;