diff options
author | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-09-10 15:39:25 +0200 |
---|---|---|
committer | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-09-10 15:39:25 +0200 |
commit | 278b76fabf31abe8fc4fbe6ca1c0ad6af830fcb7 (patch) | |
tree | a3ca8baafd3c26b6d8df3840fe92f5e2f2dd0c34 /lib/JWebmail/Model/WriteMails.pm | |
parent | 84186e77461ddeb867fa2944dcbf45217b41b80e (diff) |
added test pam to replace MockMaildir ReadMail implementation
Diffstat (limited to 'lib/JWebmail/Model/WriteMails.pm')
-rw-r--r-- | lib/JWebmail/Model/WriteMails.pm | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/lib/JWebmail/Model/WriteMails.pm b/lib/JWebmail/Model/WriteMails.pm index 751192a..330f709 100644 --- a/lib/JWebmail/Model/WriteMails.pm +++ b/lib/JWebmail/Model/WriteMails.pm @@ -1,21 +1,15 @@ package JWebmail::Model::WriteMails; -use v5.24; -use warnings; -use utf8; - -use JWebmail::Config 'SENDMAIL'; - -use Exporter 'import'; -our @EXPORT_OK = qw(sendmail); - use Email::MIME; +use namespace::clean; +use Mojo::Base -base; -our $Block_Writes = 0; +has 'sendmail_bin'; sub _build_mail { + my $self = shift; my $mail = shift; my $text_part = Email::MIME->create( @@ -51,9 +45,9 @@ sub _build_mail { sub _send { - my ($mime, @recipients) = @_; + my ($self, $mime, @recipients) = @_; - open(my $m, '|-', SENDMAIL, '-i', @recipients) + open(my $m, '|-', $self->sendmail_bin, '-i', @recipients) or die 'Connecting to sendmail failed. Is it in your PATH?'; $m->print($mime->as_string()); close($m); @@ -62,21 +56,17 @@ sub _send { sub sendmail { + my $self = shift; my $mail = shift; - my $mime = _build_mail($mail); + my $mime = $self->_build_mail($mail); my @recipients; push @recipients, @{ $mail->{to} } if $mail->{to}; push @recipients, @{ $mail->{cc} } if $mail->{cc}; push @recipients, @{ $mail->{bcc} } if $mail->{bcc}; - if ($Block_Writes) { - say $mime; - return 1; - } - - return _send($mime, @recipients); + return $self->_send($mime, @recipients); } |