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

(-)a/C4/Letters.pm (-21 / +87 lines)
Lines 44-49 BEGIN { Link Here
44
	@EXPORT = qw(
44
	@EXPORT = qw(
45
	&GetLetters &getletter &addalert &getalert &delalert &findrelatedto &SendAlerts GetPrintMessages
45
	&GetLetters &getletter &addalert &getalert &delalert &findrelatedto &SendAlerts GetPrintMessages
46
	);
46
	);
47
	@EXPORT_OK = qw( EnqueueLetter );
47
}
48
}
48
49
49
=head1 NAME
50
=head1 NAME
Lines 562-577 places a letter in the message_queue database table, which will Link Here
562
eventually get processed (sent) by the process_message_queue.pl
563
eventually get processed (sent) by the process_message_queue.pl
563
cronjob when it calls SendQueuedMessages.
564
cronjob when it calls SendQueuedMessages.
564
565
565
return true on success
566
567
=head 3 ARGUMENTS
568
569
=over 4
570
571
=item C<borrowernumber>: the borrower to receive this message
572
573
=item C<letter>: see below
574
575
=item C<message_transport_type>: 'email' or 'sms'
576
577
=item C<to_address>: the email to send the message to, if a borrowernumber is
578
not supplied.
579
580
=item C<from_address>: the address to put in the 'From' field of the email
581
582
=item C<reply_to_address>: if you want a custom reply-to, put it here
583
584
=item C<no_local_bcc>: most notices can get automatically BCCed to somewhere.
585
This doesn't do that for this message.
586
587
=back
588
589
C<letter> is a hashref containing:
590
591
=over 4
592
593
=item C<title>: the subject line
594
595
=item C<content>: the body of the message
596
597
=item C<metadata>: unused?
598
599
=item C<code>: the code for the letter, unused in the context of queued
600
messages
601
602
=item C<content-type>: the content type of the message, defaults to
603
'text/plain; charset="UTF-8"' on sending as email
604
605
=back
606
607
Not all of these are needed in all situations.
608
609
=head3 RETURNS
610
611
True if the enqueueing succeeded, false otherwise.
566
612
567
=cut
613
=cut
568
614
569
sub EnqueueLetter ($) {
615
sub EnqueueLetter ($) {
570
    my $params = shift or return undef;
616
    my $params = shift or return undef;
571
617
572
    return unless exists $params->{'letter'};
618
    unless ( exists $params->{'letter'} ) {
573
    return unless exists $params->{'borrowernumber'};
619
        carp "Need a message to send\n";
574
    return unless exists $params->{'message_transport_type'};
620
        return;
621
    }
622
    unless ( exists $params->{'borrowernumber'}
623
        || $params->{to_address} )
624
    {
625
        carp "Need a borrowernumber or a to_address to send to\n";
626
        return;
627
    }
628
    unless ( exists $params->{'message_transport_type'} ) {
629
        carp "Need to supply a message transport type\n";
630
        return;
631
    }
575
632
576
    # If we have any attachments we should encode then into the body.
633
    # If we have any attachments we should encode then into the body.
577
    if ( $params->{'attachments'} ) {
634
    if ( $params->{'attachments'} ) {
Lines 586-608 sub EnqueueLetter ($) { Link Here
586
    my $dbh       = C4::Context->dbh();
643
    my $dbh       = C4::Context->dbh();
587
    my $statement = << 'ENDSQL';
644
    my $statement = << 'ENDSQL';
588
INSERT INTO message_queue
645
INSERT INTO message_queue
589
( borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, to_address, from_address, content_type )
646
( borrowernumber, subject, content, metadata, letter_code, content_type,
647
message_transport_type, status, time_queued, to_address, from_address,
648
reply_to_address, no_local_bcc )
590
VALUES
649
VALUES
591
( ?,              ?,       ?,       ?,        ?,           ?,                      ?,      NOW(),       ?,          ?,            ? )
650
( ?,              ?,       ?,       ?,        ?,           ?,                      ?,     ?, NOW(),       ?,            ?, ?, ? )
592
ENDSQL
651
ENDSQL
593
652
594
    my $sth    = $dbh->prepare($statement);
653
    my $sth    = $dbh->prepare($statement);
595
    my $result = $sth->execute(
654
    my $result = $sth->execute(
596
        $params->{'borrowernumber'},              # borrowernumber
655
        $params->{'borrowernumber'},                # borrowernumber
597
        $params->{'letter'}->{'title'},           # subject
656
        $params->{'letter'}->{'title'},             # subject
598
        $params->{'letter'}->{'content'},         # content
657
        $params->{'letter'}->{'content'},           # content
599
        $params->{'letter'}->{'metadata'} || '',  # metadata
658
        $params->{'letter'}->{'metadata'} || '',    # metadata
600
        $params->{'letter'}->{'code'}     || '',  # letter_code
659
        $params->{'letter'}->{'code'}     || '',    # letter_code
601
        $params->{'message_transport_type'},      # message_transport_type
660
        $params->{'letter'}->{'content-type'},      # content_type
602
        'pending',                                # status
661
        $params->{'message_transport_type'},        # message_transport_type
603
        $params->{'to_address'},                  # to_address
662
        'pending',                                  # status
604
        $params->{'from_address'},                # from_address
663
        $params->{'to_address'},                    # to_address
605
        $params->{'letter'}->{'content-type'},    # content_type
664
        $params->{'from_address'},                  # from_address
665
        $params->{'reply_to_address'},              # reply_to_address
666
        $params->{'no_local_bcc'},                  # no_local_bcc
606
    );
667
    );
607
    return $result;
668
    return $result;
608
}
669
}
Lines 766-772 sub _get_unsent_messages (;$) { Link Here
766
827
767
    my $dbh = C4::Context->dbh();
828
    my $dbh = C4::Context->dbh();
768
    my $statement = << 'ENDSQL';
829
    my $statement = << 'ENDSQL';
769
SELECT message_id, borrowernumber, subject, content, message_transport_type, status, time_queued, from_address, to_address, content_type
830
SELECT message_id, borrowernumber, subject, content, message_transport_type, status, time_queued, from_address, to_address, reply_to_address, content_type
770
  FROM message_queue
831
  FROM message_queue
771
 WHERE status = ?
832
 WHERE status = ?
772
ENDSQL
833
ENDSQL
Lines 827-837 sub _send_message_by_email ($;$$$) { Link Here
827
        Message => $content,
888
        Message => $content,
828
        'content-type' => $message->{'content_type'} || 'text/plain; charset="UTF-8"',
889
        'content-type' => $message->{'content_type'} || 'text/plain; charset="UTF-8"',
829
    );
890
    );
830
    $sendmail_params{'Auth'} = {user => $username, pass => $password, method => $method} if $username;
891
    $sendmail_params{'Reply-To'} = $message->{reply_to_address}
831
    if ( my $bcc = C4::Context->preference('OverdueNoticeBcc') ) {
892
      if $message->{reply_to_address};
832
       $sendmail_params{ Bcc } = $bcc;
893
    $sendmail_params{'Auth'} =
894
      { user => $username, pass => $password, method => $method }
895
      if $username;
896
    if ( my $bcc = C4::Context->preference('OverdueNoticeBcc')
897
        && !$message->{no_local_bcc} )
898
    {
899
        $sendmail_params{Bcc} = $bcc;
833
    }
900
    }
834
    
835
901
836
    if ( sendmail( %sendmail_params ) ) {
902
    if ( sendmail( %sendmail_params ) ) {
837
        _set_message_status( { message_id => $message->{'message_id'},
903
        _set_message_status( { message_id => $message->{'message_id'},
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 2197-2202 CREATE TABLE `message_queue` ( Link Here
2197
  `to_address` mediumtext,
2197
  `to_address` mediumtext,
2198
  `from_address` mediumtext,
2198
  `from_address` mediumtext,
2199
  `content_type` text,
2199
  `content_type` text,
2200
  `reply_to_address` mediumtext,    --- an optional reply-to address for the message
2201
  `no_local_bcc` tinyint(1) DEFAULT NULL,   --- whether a copy should be sent to the address set in OverdueNoticeBcc
2200
  KEY `message_id` (`message_id`),
2202
  KEY `message_id` (`message_id`),
2201
  KEY `borrowernumber` (`borrowernumber`),
2203
  KEY `borrowernumber` (`borrowernumber`),
2202
  KEY `message_transport_type` (`message_transport_type`),
2204
  KEY `message_transport_type` (`message_transport_type`),
(-)a/installer/data/mysql/updatedatabase.pl (+2 lines)
Lines 4449-4454 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
4449
$DBversion = 'XXX';
4449
$DBversion = 'XXX';
4450
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4450
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4451
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacSendReplyTo',0,'Decides whether to use the patron\\'s email address as the reply-to when they\\'re sending carts and lists',NULL,'YesNo');");
4451
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacSendReplyTo',0,'Decides whether to use the patron\\'s email address as the reply-to when they\\'re sending carts and lists',NULL,'YesNo');");
4452
    $dbh->do("ALTER TABLE message_queue ADD COLUMN reply_to_address MEDIUMTEXT");
4453
    $dbh->do("ALTER TABLE message_queue ADD COLUMN no_local_bcc BOOLEAN");
4452
    print "Upgrade to $DBversion done (add OpacSendReplyTo syspref (enh 6973))\n";
4454
    print "Upgrade to $DBversion done (add OpacSendReplyTo syspref (enh 6973))\n";
4453
    SetVersion($DBversion);
4455
    SetVersion($DBversion);
4454
}
4456
}
(-)a/opac/opac-sendbasket.pl (-18 / +21 lines)
Lines 22-28 use CGI; Link Here
22
use Encode qw(encode);
22
use Encode qw(encode);
23
use Carp;
23
use Carp;
24
24
25
use Mail::Sendmail;
26
use MIME::QuotedPrint;
25
use MIME::QuotedPrint;
27
use MIME::Base64;
26
use MIME::Base64;
28
use C4::Biblio;
27
use C4::Biblio;
Lines 30-35 use C4::Items; Link Here
30
use C4::Auth;
29
use C4::Auth;
31
use C4::Output;
30
use C4::Output;
32
use C4::Biblio;
31
use C4::Biblio;
32
use C4::Letters qw/ EnqueueLetter /;
33
use C4::Members;
33
use C4::Members;
34
34
35
my $query = new CGI;
35
my $query = new CGI;
Lines 52-68 my $dbh = C4::Context->dbh; Link Here
52
if ( $email_add ) {
52
if ( $email_add ) {
53
    my $email_from = C4::Context->preference('KohaAdminEmailAddress');
53
    my $email_from = C4::Context->preference('KohaAdminEmailAddress');
54
    my $user = GetMember( borrowernumber => $borrowernumber );
54
    my $user = GetMember( borrowernumber => $borrowernumber );
55
    my $sender_email
55
    my $sender_email =
56
        = C4::Context->preference('OpacSendReplyTo')
56
      C4::Context->preference('OpacSendReplyTo')
57
        ? GetPreferredEmailAddress($user) || $email_from
57
      ? GetPreferredEmailAddress($user) || $email_from
58
        : $email_from;
58
      : $email_from;
59
    my $comment = $query->param('comment');
59
    my $comment = $query->param('comment');
60
    my %mail    = (
60
    my %mail    = (
61
        To         => $email_add,
61
        to_address       => $email_add,
62
        From       => $email_from,
62
        from_address     => $email_from,
63
        'Reply-To' => $sender_email,
63
        reply_to_address => $sender_email,
64
    );
64
    );
65
65
66
    # This gets filled up with the message content
67
    my %letter;
68
66
    my ( $template2, $borrowernumber, $cookie ) = get_template_and_user(
69
    my ( $template2, $borrowernumber, $cookie ) = get_template_and_user(
67
        {
70
        {
68
            template_name   => "opac-sendbasket.tmpl",
71
            template_name   => "opac-sendbasket.tmpl",
Lines 120-128 if ( $email_add ) { Link Here
120
123
121
    # Analysing information and getting mail properties
124
    # Analysing information and getting mail properties
122
    if ( $template_res =~ /<SUBJECT>\n(.*)\n<END_SUBJECT>/s ) {
125
    if ( $template_res =~ /<SUBJECT>\n(.*)\n<END_SUBJECT>/s ) {
123
        $mail{'subject'} = $1;
126
        $letter{'title'} = $1;
124
    }
127
    }
125
    else { $mail{'subject'} = "no subject"; }
128
    else { $letter{'title'} = "no subject"; }
126
129
127
    my $email_header = "";
130
    my $email_header = "";
128
    if ( $template_res =~ /<HEADER>\n(.*)\n<END_HEADER>/s ) {
131
    if ( $template_res =~ /<HEADER>\n(.*)\n<END_HEADER>/s ) {
Lines 146-155 if ( $email_add ) { Link Here
146
    #
149
    #
147
    #     # Writing mail
150
    #     # Writing mail
148
    #     $mail{body} =
151
    #     $mail{body} =
149
    $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
152
    $letter{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
150
    my $isofile = encode_base64(encode("UTF-8", $iso2709));
153
    my $isofile = encode_base64(encode("UTF-8", $iso2709));
151
    $boundary = '--' . $boundary;
154
    $boundary = '--' . $boundary;
152
    $mail{body} = <<END_OF_BODY;
155
    $letter{content} = <<END_OF_BODY;
153
$boundary
156
$boundary
154
Content-Type: text/plain; charset="utf-8"
157
Content-Type: text/plain; charset="utf-8"
155
Content-Transfer-Encoding: quoted-printable
158
Content-Transfer-Encoding: quoted-printable
Lines 165-178 $isofile Link Here
165
$boundary--
168
$boundary--
166
END_OF_BODY
169
END_OF_BODY
167
170
168
    # Sending mail
171
    $mail{letter}                 = \%letter;
169
    if ( sendmail %mail ) {
172
    $mail{message_transport_type} = 'email';
170
        # do something if it works....
173
    $mail{no_local_bcc}           = 1;
171
        $template->param( SENT      => "1" );
174
    if ( EnqueueLetter( \%mail ) ) {
175
        $template->param( SENT => "1" );
172
    }
176
    }
173
    else {
177
    else {
174
        # do something if it doesnt work....
178
        carp "Error queueing mail\n";
175
        carp "Error sending mail: $Mail::Sendmail::error \n";
176
        $template->param( error => 1 );
179
        $template->param( error => 1 );
177
    }
180
    }
178
    $template->param( email_add => $email_add );
181
    $template->param( email_add => $email_add );
(-)a/opac/opac-sendshelf.pl (-117 / +126 lines)
Lines 24-30 use CGI; Link Here
24
use Encode qw(encode);
24
use Encode qw(encode);
25
use Carp;
25
use Carp;
26
26
27
use Mail::Sendmail;
28
use MIME::QuotedPrint;
27
use MIME::QuotedPrint;
29
use MIME::Base64;
28
use MIME::Base64;
30
use C4::Auth;
29
use C4::Auth;
Lines 32-42 use C4::Biblio; Link Here
32
use C4::Items;
31
use C4::Items;
33
use C4::Output;
32
use C4::Output;
34
use C4::VirtualShelves;
33
use C4::VirtualShelves;
34
use C4::Letters qw/ EnqueueLetter /;
35
use C4::Members;
35
use C4::Members;
36
36
37
my $query = new CGI;
37
my $query = new CGI;
38
38
39
my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
39
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
40
    {
40
    {
41
        template_name   => "opac-sendshelfform.tmpl",
41
        template_name   => "opac-sendshelfform.tmpl",
42
        query           => $query,
42
        query           => $query,
Lines 46-153 my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( Link Here
46
    }
46
    }
47
);
47
);
48
48
49
my $shelfid = $query->param('shelfid');
49
my $shelfid   = $query->param('shelfid');
50
my $email   = $query->param('email');
50
my $email_add = $query->param('email');
51
51
52
my $dbh          = C4::Context->dbh;
52
my $dbh = C4::Context->dbh;
53
53
54
if ( ShelfPossibleAction( (defined($borrowernumber) ? $borrowernumber : -1), $shelfid, 'view' ) ) {
54
if (
55
55
    ShelfPossibleAction(
56
if ( $email ) {
56
        ( defined($borrowernumber) ? $borrowernumber : -1 ), $shelfid,
57
    my $email_from = C4::Context->preference('KohaAdminEmailAddress');
57
        'view'
58
    my $sender_email
58
    )
59
        = C4::Context->preference('OpacSendReplyTo')
59
  )
60
        ? GetPreferredEmailAddress($user) || $email_from
60
{
61
        : $email_from;
61
62
    my $comment = $query->param('comment');
62
    if ($email_add) {
63
63
        my $email_from = C4::Context->preference('KohaAdminEmailAddress');
64
    my %mail = (
64
        my $user = GetMember( borrowernumber => $borrowernumber );
65
        To         => $email,
65
        my $sender_email =
66
        From       => $email_from,
66
          C4::Context->preference('OpacSendReplyTo')
67
        'Reply-To' => $sender_email,
67
          ? GetPreferredEmailAddress($user) || $email_from
68
    );
68
          : $email_from;
69
69
        my $comment = $query->param('comment');
70
    my ( $template2, $borrowernumber, $cookie ) = get_template_and_user(
70
warn "Sendreplyto is: ".C4::Context->preference('OpacSendReplyTo');
71
        {
71
        my %mail = (
72
            template_name   => "opac-sendshelf.tmpl",
72
            to_address       => $email_add,
73
            query           => $query,
73
            from_address     => $email_from,
74
            type            => "opac",
74
            reply_to_address => $sender_email,
75
            authnotrequired => 1,
75
        );
76
            flagsrequired   => { borrow => 1 },
76
        my %letter;
77
78
        my ( $template2, $borrowernumber, $cookie ) = get_template_and_user(
79
            {
80
                template_name   => "opac-sendshelf.tmpl",
81
                query           => $query,
82
                type            => "opac",
83
                authnotrequired => 1,
84
                flagsrequired   => { borrow => 1 },
85
            }
86
        );
87
88
        my @shelf = GetShelf($shelfid);
89
        my ( $items, $totitems ) = GetShelfContents($shelfid);
90
        my $marcflavour = C4::Context->preference('marcflavour');
91
        my $iso2709;
92
        my @results;
93
94
        # retrieve biblios from shelf
95
        foreach my $biblio (@$items) {
96
            my $biblionumber = $biblio->{biblionumber};
97
98
            my $dat              = GetBiblioData($biblionumber);
99
            my $record           = GetMarcBiblio($biblionumber);
100
            my $marcnotesarray   = GetMarcNotes( $record, $marcflavour );
101
            my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
102
            my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
103
104
            my @items = GetItemsInfo($biblionumber);
105
106
            $dat->{MARCNOTES}      = $marcnotesarray;
107
            $dat->{MARCSUBJCTS}    = $marcsubjctsarray;
108
            $dat->{MARCAUTHORS}    = $marcauthorsarray;
109
            $dat->{'biblionumber'} = $biblionumber;
110
            $dat->{ITEM_RESULTS}   = \@items;
111
112
            $iso2709 .= $record->as_usmarc();
113
114
            push( @results, $dat );
77
        }
115
        }
78
    );
79
80
    my @shelf               = GetShelf($shelfid);
81
    my ($items, $totitems)  = GetShelfContents($shelfid);
82
    my $marcflavour         = C4::Context->preference('marcflavour');
83
    my $iso2709;
84
    my @results;
85
86
    # retrieve biblios from shelf
87
    foreach my $biblio (@$items) {
88
        my $biblionumber = $biblio->{biblionumber};
89
90
        my $dat              = GetBiblioData($biblionumber);
91
        my $record           = GetMarcBiblio($biblionumber);
92
        my $marcnotesarray   = GetMarcNotes( $record, $marcflavour );
93
        my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
94
        my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
95
96
        my @items = GetItemsInfo( $biblionumber );
97
98
        $dat->{MARCNOTES}      = $marcnotesarray;
99
        $dat->{MARCSUBJCTS}    = $marcsubjctsarray;
100
        $dat->{MARCAUTHORS}    = $marcauthorsarray;
101
        $dat->{'biblionumber'} = $biblionumber;
102
        $dat->{ITEM_RESULTS}   = \@items;
103
104
        $iso2709 .= $record->as_usmarc();
105
106
        push( @results, $dat );
107
    }
108
109
    my $user = GetMember(borrowernumber => $borrowernumber); 
110
111
    $template2->param(
112
        BIBLIO_RESULTS => \@results,
113
        email_sender   => $email_from,
114
        comment        => $comment,
115
        shelfname      => $shelf[1],
116
        firstname      => $user->{firstname},
117
        surname        => $user->{surname},
118
    );
119
116
120
    # Getting template result
117
        $template2->param(
121
    my $template_res = $template2->output();
118
            BIBLIO_RESULTS => \@results,
122
    my $body;
119
            email_sender   => $email_from,
123
120
            comment        => $comment,
124
    # Analysing information and getting mail properties
121
            shelfname      => $shelf[1],
125
    if ( $template_res =~ /<SUBJECT>\n(.*)\n<END_SUBJECT>/s ) {
122
            firstname      => $user->{firstname},
126
        $mail{'subject'} = $1;
123
            surname        => $user->{surname},
127
    }
124
        );
128
    else { $mail{'subject'} = "no subject"; }
125
126
        # Getting template result
127
        my $template_res = $template2->output();
128
        my $body;
129
130
        # Analysing information and getting mail properties
131
        if ( $template_res =~ /<SUBJECT>\n(.*)\n<END_SUBJECT>/s ) {
132
            $letter{'title'} = $1;
133
        }
134
        else { $letter{'title'} = "no subject"; }
129
135
130
    my $email_header = "";
136
        my $email_header = "";
131
    if ( $template_res =~ /<HEADER>\n(.*)\n<END_HEADER>/s ) {
137
        if ( $template_res =~ /<HEADER>\n(.*)\n<END_HEADER>/s ) {
132
        $email_header = $1;
138
            $email_header = $1;
133
    }
139
        }
134
140
135
    my $email_file = "basket.txt";
141
        my $email_file = "basket.txt";
136
    if ( $template_res =~ /<FILENAME>\n(.*)\n<END_FILENAME>/s ) {
142
        if ( $template_res =~ /<FILENAME>\n(.*)\n<END_FILENAME>/s ) {
137
        $email_file = $1;
143
            $email_file = $1;
138
    }
144
        }
139
145
140
    if ( $template_res =~ /<MESSAGE>\n(.*)\n<END_MESSAGE>/s ) { $body = encode_qp($1); }
146
        if ( $template_res =~ /<MESSAGE>\n(.*)\n<END_MESSAGE>/s ) {
147
            $body = encode_qp($1);
148
        }
141
149
142
    my $boundary = "====" . time() . "====";
150
        my $boundary = "====" . time() . "====";
143
151
144
    # We set and put the multipart content
152
        # We set and put the multipart content
145
    $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
153
        $letter{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
146
154
147
    my $isofile = encode_base64(encode("UTF-8", $iso2709));
155
        my $isofile = encode_base64( encode( "UTF-8", $iso2709 ) );
148
    $boundary = '--' . $boundary;
156
        $boundary = '--' . $boundary;
149
157
150
    $mail{body} = <<END_OF_BODY;
158
        $letter{content} = <<END_OF_BODY;
151
$boundary
159
$boundary
152
Content-Type: text/plain; charset="utf-8"
160
Content-Type: text/plain; charset="utf-8"
153
Content-Transfer-Encoding: quoted-printable
161
Content-Transfer-Encoding: quoted-printable
Lines 163-193 $isofile Link Here
163
$boundary--
171
$boundary--
164
END_OF_BODY
172
END_OF_BODY
165
173
166
    # Sending mail
174
        $mail{letter}                 = \%letter;
167
    if ( sendmail %mail ) {
175
        $mail{message_transport_type} = 'email';
168
        # do something if it works....
176
        $mail{no_local_bcc}           = 1;
169
        $template->param( SENT      => "1" );
177
        if ( EnqueueLetter( \%mail ) ) {
178
            $template->param( SENT => "1" );
179
        }
180
        else {
181
            carp "Error queueing mail\n";
182
            $template->param( error => 1 );
183
        }
184
        $template->param( email_add => $email_add );
185
        output_html_with_http_headers $query, $cookie, $template->output;
170
    }
186
    }
171
    else {
187
    else {
172
        # do something if it doesnt work....
188
        $template->param(
173
        carp "Error sending mail: $Mail::Sendmail::error \n";
189
            shelfid => $shelfid,
174
        $template->param( error => 1 );
190
            url     => "/cgi-bin/koha/opac-sendshelf.pl",
191
        );
192
        output_html_with_http_headers $query, $cookie, $template->output;
175
    }
193
    }
176
177
    $template->param( email => $email );
178
    output_html_with_http_headers $query, $cookie, $template->output;
179
180
181
}else{
182
    $template->param( shelfid => $shelfid,
183
                      url     => "/cgi-bin/koha/opac-sendshelf.pl",
184
                    );
185
    output_html_with_http_headers $query, $cookie, $template->output;
186
}
194
}
187
195
else {
188
} else {
196
    $template->param(
189
    $template->param( invalidlist => 1,
197
        invalidlistshelfid => 1,
190
                      url     => "/cgi-bin/koha/opac-sendshelf.pl",
198
        $shelfid,
199
        url => "/cgi-bin/koha/opac-sendshelf.pl",
191
    );
200
    );
192
    output_html_with_http_headers $query, $cookie, $template->output;
201
    output_html_with_http_headers $query, $cookie, $template->output;
193
}
202
}
194
- 
203

Return to bug 6973