diff options
author | Yorhel <git@yorhel.nl> | 2018-08-31 09:00:06 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2018-08-31 09:00:08 +0200 |
commit | a09cba9fd7383244bdf05c47e5fc09bc8868935f (patch) | |
tree | 15e2bdb5dc4c929257d6ef69e71f479fea5d52e4 | |
parent | ae0b833ce811311277e01660b2a48c2a811b54e0 (diff) |
Add option to write mail()s to the log
Useful when developing.
-rw-r--r-- | lib/TUWF.pod | 3 | ||||
-rw-r--r-- | lib/TUWF/Misc.pm | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/TUWF.pod b/lib/TUWF.pod index a769423..2332321 100644 --- a/lib/TUWF.pod +++ b/lib/TUWF.pod @@ -576,6 +576,9 @@ L<mail()|TUWF::Misc>. Default: C<E<lt>noreply-yawf@blicky.netE<gt>>. The path to the C<sendmail> command, used by L<mail()|TUWF::Misc>. Default: C</usr/sbin/sendmail>. +Can also be set to the string C<"log">, in which case the emails will be +written to the TUWF log function instead of actually being sent. + =item max_post_body Maximum length of the contents of POST requests, in bytes. This disallows diff --git a/lib/TUWF/Misc.pm b/lib/TUWF/Misc.pm index edea8de..dc26e88 100644 --- a/lib/TUWF/Misc.pm +++ b/lib/TUWF/Misc.pm @@ -181,7 +181,9 @@ sub TUWF::Object::mail { } $mail .= sprintf "\n%s", $body; - if(open(my $mailer, '|-:utf8', "$self->{_TUWF}{mail_sendmail} -t -f '$hs{From}'")) { + if($self->{_TUWF}{mail_sendmail} eq 'log') { + $self->log("tuwf->mail(): The following mail would have been sent:\n$mail"); + } elsif(open(my $mailer, '|-:utf8', "$self->{_TUWF}{mail_sendmail} -t -f '$hs{From}'")) { print $mailer $mail; croak "Error running sendmail ($!)" if !close($mailer); |