blob: 09c8a0d2714549d486fe1daaaac8c45e2be2a726 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package Travelynx::Helper::Sendmail;
use strict;
use warnings;
use 5.020;
use Encode qw(encode);
use Email::Sender::Simple qw(try_to_sendmail);
use Email::Simple;
sub new {
my ($class) = @_;
return bless( {}, $class );
}
sub custom {
my ( $self, $to, $subject, $body ) = @_;
my $reg_mail = Email::Simple->create(
header => [
To => $to,
From => 'Travelynx <travelynx@finalrewind.org>',
Subject => $subject,
'Content-Type' => 'text/plain; charset=UTF-8',
],
body => encode( 'utf-8', $body ),
);
if ( $self->app->config->{db}->{database} =~ m{travelynx_dev} ) {
# Do not send mail in dev mode
say "sendmail to ${to}: ${subject}\n\n${body}";
return 1;
}
return try_to_sendmail($reg_mail);
}
1;
|