$params{plaintext} = first_part $params{decrypted} if $params{decrypted};
my $tt = Template->new(INCLUDE_PATH => 'tmpl/en');
- my ($data, $subject);
+ my $data;
$tt->process($tmpl, \%params, \$data);
- $tt->process('subject', undef, \$subject);
my $email = MIME::Entity->build(
From => $ENV{EDWARDNG_FROM},
To => $in->get('From'),
- Subject => $subject,
+ Subject => 'Re: ' . $in->get('Subject'),
Data => $data);
+ my $email_unencrypted = $email->dup;
my $mg = mg always_trust => 1;
- $mg->mime_signencrypt($email, $in->get('From') =~ /<(.*)>/) and debug 'Could not encrypt message. GnuPG said ', stringify $mg->{last_message};
- sendmail $email
+ my $encrypt_failed = $mg->mime_signencrypt($email, $in->get('From') =~ /<(.*)>/);
+ debug 'Could not encrypt message, sending unencrypted. GnuPG said ', stringify $mg->{last_message} if $encrypt_failed;
+ sendmail $encrypt_failed ? $email_unencrypted : $email
}
1;
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2014 by Marius Gavrilescu
+Copyright (C) 2014 by Fundația Ceata
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.18.2 or,