mirror of https://github.com/dani/vroom.git
parent
232125b88c
commit
b4497a1e80
8 changed files with 31 additions and 188 deletions
@ -1,90 +0,0 @@ |
||||
package Mojolicious::Plugin::Mailer; |
||||
use Mojo::Base 'Mojolicious::Plugin'; |
||||
|
||||
use strict; |
||||
use warnings; |
||||
|
||||
use Email::MIME; |
||||
use Email::Sender::Simple; |
||||
use Email::Sender::Transport::Test; |
||||
use Encode; |
||||
use utf8; |
||||
|
||||
our $VERSION = '0.05'; |
||||
|
||||
|
||||
sub register { |
||||
my ($self, $app, $conf) = @_; |
||||
|
||||
$app->helper( |
||||
email => sub { |
||||
my $self = shift; |
||||
my $args = @_ ? { @_ } : return; |
||||
|
||||
|
||||
my @data = @{ $args->{data} }; |
||||
|
||||
my @parts = ( |
||||
Email::MIME->create( |
||||
body => Encode::encode('UTF-8', $self->render( |
||||
@data, |
||||
format => $args->{format} ? $args->{format} : 'email_text', |
||||
partial => 1 |
||||
)), |
||||
attributes => { |
||||
charset => 'utf-8', |
||||
encoding => '7bit', |
||||
content_type => 'text/plain', |
||||
} |
||||
), |
||||
Email::MIME->create( |
||||
body => Encode::encode('UTF-8', $self->render( |
||||
@data, |
||||
format => $args->{format} ? $args->{format} : 'email_html', |
||||
partial => 1 |
||||
)), |
||||
attributes => { |
||||
charset => 'utf-8', |
||||
encoding => '7bit', |
||||
content_type => 'text/html', |
||||
} |
||||
), |
||||
); |
||||
|
||||
my $transport = defined $args->{transport} || $conf->{transport} |
||||
? $args->{transport} || $conf->{transport} |
||||
: undef; |
||||
|
||||
my $header = { @{ $args->{header} } }; |
||||
|
||||
$header->{From} ||= $conf->{from}; |
||||
$header->{Subject} ||= $self->stash('title'); |
||||
|
||||
my $email = Email::MIME->create( |
||||
header => [ %{$header} ], |
||||
parts => [ @parts ] |
||||
); |
||||
|
||||
$email->charset_set ( $args->{charset} ? $args->{charset} : 'utf-8' ); |
||||
$email->content_type_set( $args->{content_type} ? $args->{content_type} : 'multipart/alternative' ); |
||||
|
||||
return Email::Sender::Simple->try_to_send( $email, { transport => $transport } ) if $transport; |
||||
|
||||
my $emailer = Email::Sender::Transport::Test->new; |
||||
$emailer->send_email( |
||||
$email, |
||||
{ |
||||
to => [ $header->{To} ], |
||||
from => $header->{From} |
||||
} |
||||
); |
||||
return unless $emailer->{deliveries}->[0]->{successes}->[0]; |
||||
|
||||
} |
||||
); |
||||
|
||||
} |
||||
|
||||
1; |
||||
|
||||
__END__ |
@ -1,7 +0,0 @@ |
||||
<%==l 'FROM' %>: <%= $email %> |
||||
|
||||
<%==l 'COMMENT' %>: <%== $comment %> |
||||
|
||||
-- |
||||
<%==l 'EMAIL_SIGN' %> |
||||
|
@ -1,32 +0,0 @@ |
||||
<% |
||||
my $url = $self->url_for('/')->to_abs; |
||||
$url .= ($url =~ m/\/$/) ? '' : '/'; |
||||
%> |
||||
<%==l 'YOU_ARE_INVITED_TO_A_MEETING' %> |
||||
|
||||
* <%=l 'A_MODERN_BROWSER' %> |
||||
* <%=l 'A_WEBCAM' %> |
||||
* <%=l 'A_MIC' %> |
||||
|
||||
<%==l 'WHEN_YOU_ARE_READY' %> |
||||
|
||||
<% my $roomAccess = $room; |
||||
if ($joinPass eq 'yes') { |
||||
$roomAccess .= '?token=' . $inviteId; |
||||
} |
||||
%> |
||||
<%== $url . $roomAccess %> |
||||
|
||||
<% if ($message && $message ne ''){ %> |
||||
<%==l 'MESSAGE_FROM_ORGANIZER' %>: |
||||
|
||||
<%== $message %> |
||||
<% } %> |
||||
|
||||
<%==l 'IF_YOU_CANNOT_JOIN' %> <%==l 'YOU_CAN_NOTIFY_THE_ORGANIZER' %> |
||||
|
||||
<%== $url . 'invitation?token=' . $inviteId %> |
||||
|
||||
<%==l 'HAVE_A_NICE_MEETING' %> |
||||
-- |
||||
<%==l 'EMAIL_SIGN' %> |
@ -1,17 +0,0 @@ |
||||
<% |
||||
my $url = $self->url_for('/')->to_abs; |
||||
$url .= ($url =~ m/\/$/) ? '' : '/'; |
||||
%> |
||||
<%==l 'SOMEONE_JOINED_A_ROOM' %> |
||||
|
||||
<% if ($name && $name ne ''){ %> |
||||
<%=l 'PARTICIPANT_NAME' %>: <%== $name %> |
||||
<% } %> |
||||
|
||||
<%=l 'WHEN_YOU_ARE_READY' %> |
||||
|
||||
<%== $url . $room %> |
||||
|
||||
<%=l 'HAVE_A_NICE_MEETING' %> |
||||
-- |
||||
<%==l 'EMAIL_SIGN' %> |
Loading…
Reference in new issue