diff options
Diffstat (limited to 'perllib/FixMyStreet/SendReport/Email.pm')
-rw-r--r-- | perllib/FixMyStreet/SendReport/Email.pm | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm index bac408510..7e5c10469 100644 --- a/perllib/FixMyStreet/SendReport/Email.pm +++ b/perllib/FixMyStreet/SendReport/Email.pm @@ -1,6 +1,6 @@ package FixMyStreet::SendReport::Email; -use Moose; +use Moo; use FixMyStreet::Email; BEGIN { extends 'FixMyStreet::SendReport'; } @@ -11,7 +11,7 @@ sub build_recipient_list { my $all_confirmed = 1; foreach my $body ( @{ $self->bodies } ) { - my $contact = FixMyStreet::App->model("DB::Contact")->find( { + my $contact = $row->result_source->schema->resultset("Contact")->find( { deleted => 0, body_id => $body->id, category => $row->category @@ -75,7 +75,7 @@ sub send { my $recips = $self->build_recipient_list( $row, $h ); # on a staging server send emails to ourselves rather than the bodies - if (mySociety::Config::get('STAGING_SITE') && !mySociety::Config::get('SEND_REPORTS_ON_STAGING') && !FixMyStreet->test_mode) { + if (FixMyStreet->config('STAGING_SITE') && !FixMyStreet->config('SEND_REPORTS_ON_STAGING') && !FixMyStreet->test_mode) { $recips = 1; @{$self->to} = [ $row->user->email, $self->to->[0][1] || $row->name ]; } @@ -94,23 +94,21 @@ sub send { From => $self->send_from( $row ), }; - my $app = FixMyStreet::App->new( cobrand => $cobrand ); - - $cobrand->munge_sendreport_params($app, $row, $h, $params) if $cobrand->can('munge_sendreport_params'); + $cobrand->munge_sendreport_params($row, $h, $params) if $cobrand->can('munge_sendreport_params'); $params->{Bcc} = $self->bcc if @{$self->bcc}; + my $sender = sprintf('<fms-%s@%s>', + FixMyStreet::Email::generate_verp_token('report', $row->id), + FixMyStreet->config('EMAIL_DOMAIN') + ); + if (FixMyStreet::Email::test_dmarc($params->{From}[0])) { $params->{'Reply-To'} = [ $params->{From} ]; - $params->{From} = [ mySociety::Config::get('CONTACT_EMAIL'), $params->{From}[1] ]; + $params->{From} = [ $sender, $params->{From}[1] ]; } - my $result = $app->send_email_cron( - $params, - mySociety::Config::get('CONTACT_EMAIL'), - $nomail, - $cobrand - ); + my $result = FixMyStreet::Email::send_cron($row->result_source->schema, $params, $sender, $nomail, $cobrand); unless ($result) { $self->success(1); |