~ubuntu-branches/ubuntu/dapper/swatch/dapper

« back to all changes in this revision

Viewing changes to examples/SendMail.pm

  • Committer: Bazaar Package Importer
  • Author(s): Nikolay Kokalichev
  • Date: 2004-08-02 00:00:23 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040802000023-p0rhldb331nacs2o
Tags: 3.1.1-1
 * New upstream release. (Fixes some bugs) 
   - This version is the newest version (Closes: #194052)
   - "Throttle does not work" is fixed (Closes: #254648)

 * For other fixed bugs see the upstream changelog (orig. CHANGES) file
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package Swatch::SendMail;
 
2
require 5.000;
 
3
require Exporter;
 
4
 
 
5
use strict;
 
6
use Carp;
 
7
use Mail::Sendmail;
 
8
use Sys::Hostname;
 
9
 
 
10
use 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
 
 
20
sub 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
 
 
58
E. Todd Atkins, todd.atkins@stanfordalumni.org
 
59
 
 
60
=head1 SEE ALSO
 
61
 
 
62
perl(1), swatch(1).
 
63
 
 
64
=cut
 
65
  
 
66
1;