1 |
package Nos; |
2 |
|
3 |
use 5.008; |
4 |
use strict; |
5 |
use warnings; |
6 |
|
7 |
require Exporter; |
8 |
|
9 |
our @ISA = qw(Exporter); |
10 |
|
11 |
our %EXPORT_TAGS = ( 'all' => [ qw( |
12 |
) ] ); |
13 |
|
14 |
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
15 |
|
16 |
our @EXPORT = qw( |
17 |
); |
18 |
|
19 |
our $VERSION = '0.1'; |
20 |
|
21 |
use Class::DBI::Loader; |
22 |
use Email::Valid; |
23 |
use Email::Send; |
24 |
use Carp; |
25 |
|
26 |
=head1 NAME |
27 |
|
28 |
Nos - Notice Sender core module |
29 |
|
30 |
=head1 SYNOPSIS |
31 |
|
32 |
use Nos; |
33 |
my $nos = new Nos(); |
34 |
|
35 |
=head1 DESCRIPTION |
36 |
|
37 |
Core module for notice sender's functionality. |
38 |
|
39 |
=head1 METHODS |
40 |
|
41 |
=head2 new |
42 |
|
43 |
Create new instance specifing database, user, password and options. |
44 |
|
45 |
my $nos = new Nos( |
46 |
dsn => 'dbi:Pg:dbname=notices', |
47 |
user => 'dpavlin', |
48 |
passwd => '', |
49 |
debug => 1, |
50 |
verbose => 1, |
51 |
); |
52 |
|
53 |
=cut |
54 |
|
55 |
sub new { |
56 |
my $class = shift; |
57 |
my $self = {@_}; |
58 |
bless($self, $class); |
59 |
|
60 |
$self->{'loader'} = Class::DBI::Loader->new( |
61 |
debug => $self->{'debug'}, |
62 |
dsn => $self->{'dsn'}, |
63 |
user => $self->{'user'}, |
64 |
password => $self->{'passwd'}, |
65 |
namespace => "Nos", |
66 |
# additional_classes => qw/Class::DBI::AbstractSearch/, |
67 |
# additional_base_classes => qw/My::Stuff/, |
68 |
relationships => 1, |
69 |
); |
70 |
|
71 |
$self ? return $self : return undef; |
72 |
} |
73 |
|
74 |
=head2 update_list_email |
75 |
|
76 |
Update list e-mail address |
77 |
|
78 |
$noc->update_list_email($list, 'foobar@example.com'); |
79 |
|
80 |
=cut |
81 |
|
82 |
sub update_list_email { |
83 |
my $self = shift; |
84 |
|
85 |
|
86 |
} |
87 |
|
88 |
=head2 send |
89 |
|
90 |
Send a message using configured mailer. |
91 |
|
92 |
$nos->send("message with headers"); |
93 |
|
94 |
=cut |
95 |
|
96 |
sub send_email { |
97 |
my $self = shift; |
98 |
|
99 |
my $message = shift || return; |
100 |
|
101 |
send IO => $message; |
102 |
} |
103 |
|
104 |
=head2 EXPORT |
105 |
|
106 |
None by default. |
107 |
|
108 |
=head1 SEE ALSO |
109 |
|
110 |
mailman, ezmlm, sympa, L<Mail::Salsa> |
111 |
|
112 |
=head1 AUTHOR |
113 |
|
114 |
Dobrica Pavlinusic, E<lt>dpavlin@rot13.orgE<gt> |
115 |
|
116 |
=head1 COPYRIGHT AND LICENSE |
117 |
|
118 |
Copyright (C) 2005 by Dobrica Pavlinusic |
119 |
|
120 |
This library is free software; you can redistribute it and/or modify |
121 |
it under the same terms as Perl itself, either Perl version 5.8.4 or, |
122 |
at your option, any later version of Perl 5 you may have available. |
123 |
|
124 |
|
125 |
=cut |