diff options
author | Matthew Somerville <matthew@mysociety.org> | 2015-09-25 17:30:10 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2015-12-02 17:41:21 +0000 |
commit | bb1e7974955b450520489b93f8ddb6fedaf96008 (patch) | |
tree | eb509af1f0dcc81089c9260304f26a067c717254 /perllib/FixMyStreet/App/Model | |
parent | 361f9e49c2e8c5aee1c4bdb9bd7897bba6f6f06b (diff) |
Move EmailSend out of Catalyst for use elsewhere.
Diffstat (limited to 'perllib/FixMyStreet/App/Model')
-rw-r--r-- | perllib/FixMyStreet/App/Model/EmailSend.pm | 55 |
1 files changed, 2 insertions, 53 deletions
diff --git a/perllib/FixMyStreet/App/Model/EmailSend.pm b/perllib/FixMyStreet/App/Model/EmailSend.pm index 475026267..93751d4a6 100644 --- a/perllib/FixMyStreet/App/Model/EmailSend.pm +++ b/perllib/FixMyStreet/App/Model/EmailSend.pm @@ -4,67 +4,16 @@ use base 'Catalyst::Model::Factory'; use strict; use warnings; -use FixMyStreet; -use Email::Send; - =head1 NAME FixMyStreet::App::Model::EmailSend =head1 DESCRIPTION -Thin wrapper around Email::Send - configuring it correctly acording to our config. - -If the config value 'SMTP_SMARTHOST' is set then email is routed via SMTP to -that. Otherwise it is sent using a 'sendmail' like binary on the local system. - -And finally if if FixMyStreet->test_mode returns true then emails are not sent -at all but are stored in memory for the test suite to inspect (using -Email::Send::Test). +Catalyst Model wrapper around FixMyStreet::EmailSend =cut -my $args = undef; - -if ( FixMyStreet->test_mode ) { - - # Email::Send::Test - $args = { mailer => 'Test', }; -} -elsif ( my $smtp_host = FixMyStreet->config('SMTP_SMARTHOST') ) { - - # Email::Send::SMTP - my $type = FixMyStreet->config('SMTP_TYPE') || ''; - my $port = FixMyStreet->config('SMTP_PORT') || ''; - my $username = FixMyStreet->config('SMTP_USERNAME') || ''; - my $password = FixMyStreet->config('SMTP_PASSWORD') || ''; - - unless ($port) { - $port = 25; - $port = 465 if $type eq 'ssl'; - $port = 587 if $type eq 'tls'; - } - - my $mailer_args = [ - Host => $smtp_host, - Port => $port, - ]; - push @$mailer_args, ssl => 1 if $type eq 'ssl'; - push @$mailer_args, tls => 1 if $type eq 'tls'; - push @$mailer_args, username => $username, password => $password - if $username && $password; - $args = { - mailer => 'FixMyStreet::EmailSend::DoNotReply', - mailer_args => $mailer_args, - }; -} -else { - - # Email::Send::Sendmail - $args = { mailer => 'Sendmail' }; -} - __PACKAGE__->config( - class => 'Email::Send', - args => $args, + class => 'FixMyStreet::EmailSend', ); |