1 package Koha::SMTP::Server;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21 use Koha::Exceptions::Object;
22 use Koha::SMTP::Servers;
24 use Email::Sender::Transport::SMTP;
26 use base qw(Koha::Object);
30 Koha::SMTP::Server - Koha SMTP Server Object class
38 my $transport = $smtp_server->transport;
39 sendmail( $message, { transport => $transport } );
41 Returns an I<Email::Sender::Transport::SMTP> object that can be used directly
54 $params->{ssl} = $self->ssl_mode
55 unless $self->ssl_mode eq 'disabled';
57 $params->{timeout} = $self->timeout
60 $params->{sasl_username} = $self->user_name
63 $params->{sasl_password} = $self->password
67 my $transport = Email::Sender::Transport::SMTP->new( $params );
74 my $libraries = $smtp_server->libraries
76 Accessor to get the list of libraries that are linked to this SMTP server
83 my @library_ids = $self->_result->library_smtp_servers->get_column('library_id')->all;
84 return Koha::Libraries->search( { branchcode => { -in => \@library_ids } } );
87 =head3 is_system_default
89 if ( $smtp_server->is_system_default ) { ... }
91 Method that tells if a Koha::SMTP::Server is the hardcoded one.
95 sub is_system_default {
98 return $self->{_is_system_default};
101 =head3 to_api_mapping
103 This method returns the mapping for representing a Koha::SMTP::Server object
110 id => 'smtp_server_id'
114 =head2 Internal methods
118 Return type of Object relating to Schema ResultSet