File: SendMail.pm

package info (click to toggle)
swatch 3.1.1-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 180 kB
  • ctags: 24
  • sloc: perl: 1,116; makefile: 53
file content (66 lines) | stat: -rw-r--r-- 1,158 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package Swatch::SendMail;
require 5.000;
require Exporter;

use strict;
use Carp;
use Mail::Sendmail;
use Sys::Hostname;

use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);

@ISA = qw(Exporter);
@EXPORT = qw/
  &send_mail
/;
$VERSION = '20031118';

################################################################

sub send_mail {
  my $login = (getpwuid($<))[0];
  my $host = hostname;
  my %opts = (
              'ADDRESSES' => $login,
              'FROM' => "$login\@$host",
              'SUBJECT' => 'Message from Swatch',
	      @_
  );

  (my $to_line = $opts{'ADDRESSES'}) =~ s/:/,/g;

  my %mail = ( To => $to_line,
               From => $opts{FROM},,
	       Subject => $opts{SUBJECT},
	       Message => $opts{MESSAGE},
  );
  sendmail(%mail) or warn $Mail::Sendmail::error;
  return 0;
}

################################################################
## The POD ###

=head1 NAME

  Swatch::SendMail - Swatch interface to the Mail::Sendmail module

=head1 SYNOPSIS

  use Swatch::SendMail;

=head1 SWATCH SYNTAX

=head1 DESCRIPTION

=head1 AUTHOR

E. Todd Atkins, todd.atkins@stanfordalumni.org

=head1 SEE ALSO

perl(1), swatch(1).

=cut
  
1;