/[Frey]/trunk/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

Annotation of /trunk/lib/App/RoomReservation/Email.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1134 - (hide annotations)
Tue Jun 30 15:59:41 2009 UTC (14 years, 10 months ago) by dpavlin
File size: 896 byte(s)
added e-mail sending
1 dpavlin 1134 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 "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{FREY_HOSTNAME}{192.168.1.13:3000}gs;
25     $body =~ s{^\s+}{}gm; # strip whitespace at beginning of line
26     $body =~ s{<[^>]+/?>}{}gs; # strip html
27    
28     my $m = Email::Simple->create(
29     header => [
30     To => $to,
31     From => '"Room Reservation" <room-reservation@rot13.org>',
32     Subject => $subject,
33     ],
34     body => $body,
35     );
36    
37     sendmail($m);
38    
39     warn "# send to $to\n$body\n";
40     }
41    
42     no Moose::Role;
43    
44     1;

  ViewVC Help
Powered by ViewVC 1.1.26