View | Details | Raw Unified | Return to bug 22343
Collapse All | Expand All

(-)a/basket/sendbasket.pl (-18 / +17 lines)
Lines 30-36 use C4::Templates (); Link Here
30
use Koha::Email;
30
use Koha::Email;
31
use Koha::Token;
31
use Koha::Token;
32
32
33
my $query = new CGI;
33
my $query = CGI->new;
34
34
35
my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
35
my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
36
    {
36
    {
Lines 114-137 if ( $email_add ) { Link Here
114
        $subject = "no subject";
114
        $subject = "no subject";
115
    }
115
    }
116
116
117
    my $email = Koha::Email->create(
118
        {
119
            to      => $email_add,
120
            subject => $subject,
121
        }
122
    );
123
124
    my $email_header = "";
117
    my $email_header = "";
125
    if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) {
118
    if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) {
126
        $email_header = $1;
119
        $email_header = $1;
127
        $email_header =~ s|\n?(.*)\n?|$1|;
120
        $email_header =~ s|\n?(.*)\n?|$1|;
128
        $email_header = Encode::encode("UTF-8", $email_header);
129
    }
121
    }
130
122
131
    if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) {
123
    if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) {
132
        $body = $1;
124
        $body = $1;
133
        $body =~ s|\n?(.*)\n?|$1|;
125
        $body =~ s|\n?(.*)\n?|$1|;
134
        $body = Encode::encode("UTF-8", $body);
135
    }
126
    }
136
127
137
    my $THE_body = <<END_OF_BODY;
128
    my $THE_body = <<END_OF_BODY;
Lines 139-153 $email_header Link Here
139
$body
130
$body
140
END_OF_BODY
131
END_OF_BODY
141
132
142
    $email->text_body( $THE_body );
143
    $email->attach(
144
        $iso2709,
145
        content_type => 'application/octet-stream',
146
        name         => 'basket.iso2709',
147
        disposition  => 'attachment',
148
    );
149
150
    try {
133
    try {
134
135
        my $email = Koha::Email->create(
136
            {
137
                to      => $email_add,
138
                subject => $subject,
139
            }
140
        );
141
142
        $email->text_body( $THE_body );
143
        $email->attach(
144
            Encode::encode( "UTF-8", $iso2709 ),
145
            content_type => 'application/octet-stream',
146
            name         => 'basket.iso2709',
147
            disposition  => 'attachment',
148
        );
149
151
        my $library = Koha::Patrons->find( $borrowernumber )->library;
150
        my $library = Koha::Patrons->find( $borrowernumber )->library;
152
        $email->send_or_die({ transport => $library->smtp_server->transport });
151
        $email->send_or_die({ transport => $library->smtp_server->transport });
153
        $template->param( SENT => "1" );
152
        $template->param( SENT => "1" );
(-)a/opac/opac-sendbasket.pl (-20 / +15 lines)
Lines 34-40 use Koha::Email; Link Here
34
use Koha::Patrons;
34
use Koha::Patrons;
35
use Koha::Token;
35
use Koha::Token;
36
36
37
my $query = new CGI;
37
my $query = CGI->new;
38
38
39
my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
39
my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
40
    {
40
    {
Lines 127-152 if ( $email_add ) { Link Here
127
        $subject = "no subject";
127
        $subject = "no subject";
128
    }
128
    }
129
129
130
    # if you want to use the KohaAdmin address as from, that is the default no need to set it
131
    my $email = Koha::Email->create({
132
        to       => $email_add,
133
        reply_to => $email_replyto,
134
        subject  => $subject,
135
    });
136
137
    $email->header( 'X-Abuse-Report' => C4::Context->preference('KohaAdminEmailAddress') );
138
139
    my $email_header = "";
130
    my $email_header = "";
140
    if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) {
131
    if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) {
141
        $email_header = $1;
132
        $email_header = $1;
142
        $email_header =~ s|\n?(.*)\n?|$1|;
133
        $email_header =~ s|\n?(.*)\n?|$1|;
143
        $email_header = Encode::encode("UTF-8", $email_header);
144
    }
134
    }
145
135
146
    if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) {
136
    if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) {
147
        $body = $1;
137
        $body = $1;
148
        $body =~ s|\n?(.*)\n?|$1|;
138
        $body =~ s|\n?(.*)\n?|$1|;
149
        $body = Encode::encode("UTF-8", $body);
150
    }
139
    }
151
140
152
    my $THE_body = <<END_OF_BODY;
141
    my $THE_body = <<END_OF_BODY;
Lines 154-173 $email_header Link Here
154
$body
143
$body
155
END_OF_BODY
144
END_OF_BODY
156
145
157
    $email->text_body( $THE_body );
158
    $email->attach(
159
        $iso2709,
160
        content_type => 'application/octet-stream',
161
        name         => 'basket.iso2709',
162
        disposition  => 'attachment',
163
    );
164
165
    if ( !defined $iso2709 ) {
146
    if ( !defined $iso2709 ) {
166
        carp "Error sending mail: empty basket";
147
        carp "Error sending mail: empty basket";
167
        $template->param( error => 1 );
148
        $template->param( error => 1 );
168
    }
149
    }
169
    else {
150
    else {
170
        try {
151
        try {
152
            # if you want to use the KohaAdmin address as from, that is the default no need to set it
153
            my $email = Koha::Email->create({
154
                to       => $email_add,
155
                reply_to => $email_replyto,
156
                subject  => $subject,
157
            });
158
            $email->header( 'X-Abuse-Report' => C4::Context->preference('KohaAdminEmailAddress') );
159
            $email->text_body( $THE_body );
160
            $email->attach(
161
                Encode::encode( "UTF-8", $iso2709 ),
162
                content_type => 'application/octet-stream',
163
                name         => 'basket.iso2709',
164
                disposition  => 'attachment',
165
            );
171
            my $library = $patron->library;
166
            my $library = $patron->library;
172
            $email->transport( $library->smtp_server->transport );
167
            $email->transport( $library->smtp_server->transport );
173
            $email->send_or_die;
168
            $email->send_or_die;
(-)a/opac/opac-sendshelf.pl (-17 / +13 lines)
Lines 128-151 if ( $email ) { Link Here
128
        $subject = "no subject";
128
        $subject = "no subject";
129
    }
129
    }
130
130
131
    my $email = Koha::Email->create(
132
        {
133
            to      => $email,
134
            subject => $subject,
135
        }
136
    );
137
138
    my $email_header = "";
131
    my $email_header = "";
139
    if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) {
132
    if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) {
140
        $email_header = $1;
133
        $email_header = $1;
141
        $email_header =~ s|\n?(.*)\n?|$1|;
134
        $email_header =~ s|\n?(.*)\n?|$1|;
142
        $email_header = Encode::encode("UTF-8", $email_header);
143
    }
135
    }
144
136
145
    if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) {
137
    if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) {
146
        $body = $1;
138
        $body = $1;
147
        $body =~ s|\n?(.*)\n?|$1|;
139
        $body =~ s|\n?(.*)\n?|$1|;
148
        $body = Encode::encode("UTF-8", $body);
149
    }
140
    }
150
141
151
    my $THE_body = <<END_OF_BODY;
142
    my $THE_body = <<END_OF_BODY;
Lines 153-167 $email_header Link Here
153
$body
144
$body
154
END_OF_BODY
145
END_OF_BODY
155
146
156
    $email->text_body( $THE_body );
157
    $email->attach(
158
        $iso2709,
159
        content_type => 'application/octet-stream',
160
        name         => 'list.iso2709',
161
        disposition  => 'attachment',
162
    );
163
164
    try {
147
    try {
148
        my $email = Koha::Email->create(
149
            {
150
                to      => $email,
151
                subject => $subject,
152
            }
153
        );
154
        $email->text_body( $THE_body );
155
        $email->attach(
156
            Encode::encode( "UTF-8", $iso2709 ),
157
            content_type => 'application/octet-stream',
158
            name         => 'list.iso2709',
159
            disposition  => 'attachment',
160
        );
165
        my $library = Koha::Patrons->find( $borrowernumber )->library;
161
        my $library = Koha::Patrons->find( $borrowernumber )->library;
166
        $email->transport( $library->smtp_server->transport );
162
        $email->transport( $library->smtp_server->transport );
167
        $email->send_or_die;
163
        $email->send_or_die;
(-)a/virtualshelves/sendshelf.pl (-20 / +16 lines)
Lines 31-37 use C4::Output; Link Here
31
use Koha::Email;
31
use Koha::Email;
32
use Koha::Virtualshelves;
32
use Koha::Virtualshelves;
33
33
34
my $query = new CGI;
34
my $query = CGI->new;
35
35
36
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
36
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
37
    {
37
    {
Lines 108-131 if ($to_address) { Link Here
108
        $subject = "no subject";
108
        $subject = "no subject";
109
    }
109
    }
110
110
111
    my $email = Koha::Email->create(
112
        {
113
            to      => $to_address,
114
            subject => $subject,
115
        }
116
    );
117
118
    my $email_header = "";
111
    my $email_header = "";
119
    if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) {
112
    if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) {
120
        $email_header = $1;
113
        $email_header = $1;
121
        $email_header =~ s|\n?(.*)\n?|$1|;
114
        $email_header =~ s|\n?(.*)\n?|$1|;
122
        $email_header = Encode::encode("UTF-8", $email_header);
123
    }
115
    }
124
116
125
    if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) {
117
    if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) {
126
        $body = $1;
118
        $body = $1;
127
        $body =~ s|\n?(.*)\n?|$1|;
119
        $body =~ s|\n?(.*)\n?|$1|;
128
        $body = Encode::encode("UTF-8", $body);
129
    }
120
    }
130
121
131
    my $THE_body = <<END_OF_BODY;
122
    my $THE_body = <<END_OF_BODY;
Lines 133-147 $email_header Link Here
133
$body
124
$body
134
END_OF_BODY
125
END_OF_BODY
135
126
136
    $email->text_body( $THE_body );
137
    $email->attach(
138
        $iso2709,
139
        content_type => 'application/octet-stream',
140
        name         => 'shelf.iso2709',
141
        disposition  => 'attachment',
142
    );
143
144
    try {
127
    try {
128
        my $email = Koha::Email->create(
129
            {
130
                to      => $to_address,
131
                subject => $subject,
132
            }
133
        );
134
        $email->text_body( $THE_body );
135
        $email->attach(
136
            Encode::encode("UTF-8", $iso2709),
137
            content_type => 'application/octet-stream',
138
            name         => 'shelf.iso2709',
139
            disposition  => 'attachment',
140
        );
141
145
        my $library = Koha::Patrons->find( $borrowernumber )->library;
142
        my $library = Koha::Patrons->find( $borrowernumber )->library;
146
        $email->send_or_die({ transport => $library->smtp_server->transport });
143
        $email->send_or_die({ transport => $library->smtp_server->transport });
147
        $template->param( SENT => "1" );
144
        $template->param( SENT => "1" );
Lines 151-157 END_OF_BODY Link Here
151
        $template->param( error => 1 );
148
        $template->param( error => 1 );
152
    };
149
    };
153
150
154
    $template->param( email => $email );
151
    $template->param( email => $to_address );
155
    output_html_with_http_headers $query, $cookie, $template->output;
152
    output_html_with_http_headers $query, $cookie, $template->output;
156
153
157
}
154
}
158
- 

Return to bug 22343