line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Application::Plugin::Email;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
CGI::Application::Plugin::Email - Lazy loaded Email
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Just a little wrapper around Email::Stuff. Useful to add easy emailing
|
11
|
|
|
|
|
|
|
functionality without loading having to load the library unless it's actually
|
12
|
|
|
|
|
|
|
called.
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use CGI::Application::Plugin::Email qw( :std );
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Creating a new Email::Stuff object:-
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$email = $self->Email->new;
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
If you aren't happy with importing a method named C into your namespace
|
21
|
|
|
|
|
|
|
then you can choose the method name:-
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use CGI::Application::Plugin::Email ( ':std', { method => 'EmailStuff' } );
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Creating a new Email::Stuff object:-
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$email = $self->EmailStuff->new;
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This module is a wrapper around C.
|
33
|
|
|
|
|
|
|
The only real benefit is the lazy loading so that Email::Stuff isn't loaded with
|
34
|
|
|
|
|
|
|
every request. This makes it a good option for scripts running through CGI.
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 Methods
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 Email
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
This is the object that gets exported.
|
41
|
|
|
|
|
|
|
See L
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 Export groups
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Only an Email:::Stuff object can be exported. It's not exported by default,
|
46
|
|
|
|
|
|
|
but this module is pretty useless without it. You can choose the name of the
|
47
|
|
|
|
|
|
|
method that invokes the object.
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
:std exports:-
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Email
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 FAQ
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 How do I send email?
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
View the L documentation on how to use the returned email object
|
58
|
|
|
|
|
|
|
to send mail.
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 Why?
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Emailing can be a pain, wanted a quick and easy way of doing it. Email::Stuff
|
63
|
|
|
|
|
|
|
provides that, but I didn't want it slowing down my cgi requests that didn't
|
64
|
|
|
|
|
|
|
actually use it. Also there were no CGI::Application plugins for sending email,
|
65
|
|
|
|
|
|
|
so a plugin providing an easy path to emailing for new people seemed a good
|
66
|
|
|
|
|
|
|
idea :)
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 Thanks to:-
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
L
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Adam Kennedy for creating Email::Stuff and for making sure it had Pure Perl
|
73
|
|
|
|
|
|
|
dependency options when I asked him :)
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 Come join the bestest Perl group in the World!
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Bristol and Bath Perl moungers is renowned for being the friendliest Perl group
|
78
|
|
|
|
|
|
|
in the world. You don't have to be from the UK to join, everyone is welcome on
|
79
|
|
|
|
|
|
|
the list:-
|
80
|
|
|
|
|
|
|
L
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Lyle Hopkins ;)
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
1
|
|
25671
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
91
|
1
|
|
|
1
|
|
6
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
92
|
1
|
|
|
1
|
|
6
|
use Carp;
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
77
|
|
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
1
|
|
5
|
use vars qw ( $VERSION @ISA @EXPORT_OK %EXPORT_TAGS );
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
363
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
require Exporter;
|
97
|
|
|
|
|
|
|
@ISA = qw(Exporter);
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
@EXPORT_OK = ();
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
%EXPORT_TAGS = (
|
102
|
|
|
|
|
|
|
std => [],
|
103
|
|
|
|
|
|
|
);
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$VERSION = '0.01';
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my $email;
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub import {
|
110
|
1
|
|
|
1
|
|
16
|
$email = new__ CGI::Application::Plugin::Email::guts;
|
111
|
1
|
|
|
|
|
2
|
my $exportmethod = 'Email';
|
112
|
1
|
50
|
|
|
|
10
|
if ( ref $_[ $#_ ] eq 'HASH' ) {
|
113
|
0
|
|
|
|
|
0
|
my $attrib = pop @_;
|
114
|
0
|
0
|
|
|
|
0
|
$exportmethod = $attrib->{method} if ( $attrib->{method} );
|
115
|
|
|
|
|
|
|
}#if
|
116
|
|
|
|
|
|
|
### Check name if legal
|
117
|
1
|
50
|
|
|
|
8
|
unless ( $exportmethod =~ /^[0-9a-z_]+$/i ) {
|
118
|
0
|
|
|
|
|
0
|
croak( "Illegal export method name" );
|
119
|
|
|
|
|
|
|
}#unless
|
120
|
1
|
|
|
|
|
3
|
push( @EXPORT_OK, $exportmethod );
|
121
|
1
|
|
|
|
|
2
|
push( @{ $EXPORT_TAGS{std} }, $exportmethod );
|
|
1
|
|
|
|
|
3
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
{
|
124
|
1
|
|
|
1
|
|
7
|
no strict 'refs';
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
270
|
|
|
1
|
|
|
|
|
2
|
|
125
|
1
|
|
|
|
|
6
|
*{ $exportmethod } = sub {
|
126
|
0
|
0
|
|
0
|
|
0
|
unless ( $email->{params}->{__loaded} ) {
|
127
|
0
|
|
|
|
|
0
|
$email->__LoadEmail();
|
128
|
|
|
|
|
|
|
}#unless
|
129
|
0
|
|
|
|
|
0
|
return $email;
|
130
|
|
|
|
|
|
|
}#sub
|
131
|
1
|
|
|
|
|
5
|
}#block
|
132
|
|
|
|
|
|
|
|
133
|
1
|
|
|
|
|
96
|
CGI::Application::Plugin::Email->export_to_level(1, @_);
|
134
|
|
|
|
|
|
|
}#sub
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
package CGI::Application::Plugin::Email::guts;
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub new__ {
|
142
|
1
|
|
|
1
|
|
3
|
my $class = shift;
|
143
|
1
|
|
|
|
|
2
|
my $obj = {};
|
144
|
1
|
|
|
|
|
4
|
bless( $obj, $class );
|
145
|
1
|
|
|
|
|
3
|
return $obj;
|
146
|
|
|
|
|
|
|
}#sub
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub new {
|
150
|
0
|
|
|
0
|
|
|
shift;
|
151
|
0
|
|
|
|
|
|
return Email::Stuff->new( @_ );
|
152
|
|
|
|
|
|
|
}#sub
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub __LoadEmail {
|
156
|
0
|
|
|
0
|
|
|
require Email::Stuff;
|
157
|
0
|
|
|
|
|
|
import Email::Stuff;
|
158
|
|
|
|
|
|
|
}#sub
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1;
|