Bugzilla – Attachment 108648 Details for
Bug 22343
Add configuration options for SMTP servers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22343: Add ->transport method
Bug-22343-Add--transport-method.patch (text/plain), 3.71 KB, created by
Kyle M Hall (khall)
on 2020-08-19 15:16:37 UTC
(
hide
)
Description:
Bug 22343: Add ->transport method
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-08-19 15:16:37 UTC
Size:
3.71 KB
patch
obsolete
>From a8fb3dd5d1e492d9caf0c144d45a40e7e1cb4201 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 5 Aug 2020 16:22:32 -0300 >Subject: [PATCH] Bug 22343: Add ->transport method > >This patch adds a Koha::SMTP::Server->transport method that returns an >Email::Sender::Transport::SMTP object generated with the current >object's settings. Special case is handled for disabled SSL. > >This is all covered by the introduced tests. > >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/SMTP/Server.t >=> SUCCESS: Tests pass! > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/SMTP/Server.pm | 38 +++++++++++++++++++++++++++++++ > cpanfile | 1 + > t/db_dependent/Koha/SMTP/Server.t | 29 ++++++++++++++++++++++- > 3 files changed, 67 insertions(+), 1 deletion(-) > >diff --git a/Koha/SMTP/Server.pm b/Koha/SMTP/Server.pm >index 5a078941c1..874c6624d1 100644 >--- a/Koha/SMTP/Server.pm >+++ b/Koha/SMTP/Server.pm >@@ -21,6 +21,8 @@ use Koha::Database; > use Koha::Exceptions::Object; > use Koha::SMTP::Servers; > >+use Email::Sender::Transport::SMTP; >+ > use base qw(Koha::Object); > > =head1 NAME >@@ -100,6 +102,42 @@ sub library { > return Koha::Library->_new_from_dbic($self->_result->library); > } > >+=head3 transport >+ >+ my $transport = $smtp_server->transport; >+ sendmail( $message, { transport => $transport } ); >+ >+Returns an I<Email::Sender::Transport::SMTP> object that can be used directly >+with Email::Sender. >+ >+=cut >+ >+sub transport { >+ my ($self) = @_; >+ >+ my $params = { >+ host => $self->host, >+ port => $self->port, >+ }; >+ >+ $params->{ssl} = $self->ssl_mode >+ unless $self->ssl_mode eq 'disabled'; >+ >+ $params->{timeout} = $self->timeout >+ if $self->timeout; >+ >+ $params->{sasl_username} = $self->user_name >+ if $self->user_name; >+ >+ $params->{sasl_password} = $self->password >+ if $self->password; >+ >+ >+ my $transport = Email::Sender::Transport::SMTP->new( $params ); >+ >+ return $transport; >+} >+ > =head3 to_api_mapping > > This method returns the mapping for representing a Koha::SMTP::Server object >diff --git a/cpanfile b/cpanfile >index 7e5eeaa1d8..05ae2aa495 100644 >--- a/cpanfile >+++ b/cpanfile >@@ -36,6 +36,7 @@ requires 'Digest::MD5', '2.36'; > requires 'Digest::SHA', '5.43'; > requires 'Email::Date', '1.103'; > requires 'Email::MessageID', '1.406'; >+requires 'Email::Sender', '1.300030'; > requires 'Email::Valid', '0.190'; > requires 'Exception::Class', '1.38'; > requires 'File::Slurp', '9999.13'; >diff --git a/t/db_dependent/Koha/SMTP/Server.t b/t/db_dependent/Koha/SMTP/Server.t >index db7b1f65af..9b8beb9a06 100644 >--- a/t/db_dependent/Koha/SMTP/Server.t >+++ b/t/db_dependent/Koha/SMTP/Server.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 3; > use Test::Exception; > use Test::Warn; > >@@ -118,3 +118,30 @@ subtest 'store() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'transport() tests' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $server = $builder->build_object( >+ { >+ class => 'Koha::SMTP::Servers', >+ value => { ssl_mode => 'disabled' } >+ } >+ ); >+ >+ my $transport = $server->transport; >+ >+ is( ref($transport), 'Email::Sender::Transport::SMTP', 'Type is correct' ); >+ is( $transport->ssl, 0, 'SSL is not set' ); >+ >+ $server->set({ ssl_mode => 'ssl' })->store; >+ $transport = $server->transport; >+ >+ is( ref($transport), 'Email::Sender::Transport::SMTP', 'Type is correct' ); >+ is( $transport->ssl, 'ssl', 'SSL is set' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.24.1 (Apple Git-126)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22343
:
107598
|
107599
|
107600
|
107601
|
107602
|
107603
|
107604
|
107605
|
107987
|
107988
|
107989
|
107990
|
107991
|
107992
|
107993
|
107994
|
107995
|
107996
|
107997
|
107998
|
107999
|
108009
|
108107
|
108108
|
108109
|
108110
|
108111
|
108112
|
108113
|
108114
|
108115
|
108116
|
108117
|
108118
|
108119
|
108131
|
108132
|
108133
|
108134
|
108135
|
108136
|
108137
|
108138
|
108139
|
108140
|
108141
|
108142
|
108143
|
108529
|
108537
|
108538
|
108539
|
108540
|
108541
|
108542
|
108543
|
108544
|
108545
|
108546
|
108547
|
108548
|
108549
|
108609
|
108638
|
108642
|
108643
|
108644
|
108645
|
108646
|
108647
|
108648
|
108649
|
108650
|
108651
|
108652
|
108653
|
108654
|
108655
|
108656
|
108715
|
108716
|
109003
|
109004
|
109005
|
109006
|
109007
|
109008
|
109009
|
109010
|
109011
|
109012
|
109013
|
109014
|
109015
|
109016
|
109017
|
109018
|
109155
|
109156
|
109157
|
109158
|
109159
|
109160
|
109161
|
109162
|
109163
|
109164
|
109165
|
109166
|
109167
|
109168
|
109169
|
109170
|
109601
|
109602
|
109603
|
109604
|
109605
|
109606
|
109607
|
109608
|
109609
|
109610
|
109611
|
109612
|
109613
|
109614
|
109615
|
109616
|
109723
|
109724
|
109725
|
109726
|
109727
|
109728
|
109729
|
109730
|
109731
|
109732
|
109733
|
109734
|
109735
|
109736
|
109737
|
109738
|
109739
|
109740
|
109787
|
109788
|
111048
|
111087
|
111088
|
111089
|
111090
|
111154
|
111165
|
111166
|
111175
|
111176
|
111213
|
111215
|
111216
|
111442
|
111482
|
113240
|
113827
|
113847