/[Frey]/branches/zimbardo/lib/App/RoomReservation/Email.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /branches/zimbardo/lib/App/RoomReservation/Email.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1181 - (show annotations)
Tue Jul 7 22:07:51 2009 UTC (14 years, 9 months ago) by dpavlin
File size: 967 byte(s)
 r4308@llin (orig r1175):  dpavlin | 2009-07-06 22:27:57 +0200
 adaptive length of input type=text on form using new form_value_len
 which is implemented by App class
 r4309@llin (orig r1176):  dpavlin | 2009-07-07 14:28:59 +0200
 fix revert and postpone for first file in diff
 r4310@llin (orig r1177):  dpavlin | 2009-07-07 22:11:24 +0200
 take a look at new mst toy (DBIx::Class refactoring into Moose goodness)
 r4311@llin (orig r1178):  dpavlin | 2009-07-07 22:11:44 +0200
 use number of seats from room definition
 r4312@llin (orig r1179):  dpavlin | 2009-07-07 22:12:50 +0200
 wrap title call to application class in eval (sometimes it needs instance of class)
 r4313@llin (orig r1180):  dpavlin | 2009-07-07 22:53:55 +0200
 added mime headers and charset

1 package App::RoomReservation::Email;
2 use Moose::Role;
3
4 use Email::Sender::Simple qw(sendmail);
5 use Email::Simple;
6 use Email::Simple::Creator;
7
8 requires 'dbh';
9
10 sub send {
11 my ($self, $email, $subject, $body) = @_;
12
13 my $sth = $self->dbh->prepare(qq{
14 select ime,prezime from reservation where email = ?
15 });
16
17 $sth->execute($email);
18
19 die qq|<error>Can't find registered user with e-mail $email| unless $sth->rows == 1;
20
21 my ($ime,$prezime) = $sth->fetchrow_array;
22 my $to = qq{"$ime $prezime" <$email>};
23
24 $body =~ s{^\s+}{}gm; # strip whitespace at beginning of line
25 $body =~ s{<br>}{\n}gs;
26 $body =~ s{<[^>]+/?>}{}gs; # strip html
27
28 my $m = Email::Simple->create(
29 header => [
30 To => $to,
31 From => '<predavanje_psih@ffzg.hr>',
32 Subject => $subject,
33 'X-Mailer' => __PACKAGE__,
34 'MIME-Version' => '1.0',
35 'Content-Type' => 'text/plain; charset=utf-8',
36 ],
37 body => $body,
38 );
39
40 sendmail($m);
41
42 warn "# send to $to\n$body\n";
43 }
44
45 no Moose::Role;
46
47 1;

  ViewVC Help
Powered by ViewVC 1.1.26