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

(-)a/C4/Letters.pm (-11 / +16 lines)
Lines 330-340 sub SendAlerts { Link Here
330
            # FIXME: This 'default' behaviour should be moved to Koha::Email
330
            # FIXME: This 'default' behaviour should be moved to Koha::Email
331
            my $mail = Koha::Email->create(
331
            my $mail = Koha::Email->create(
332
                {
332
                {
333
                    to       => $email,
333
                    to          => $email,
334
                    from     => $library->branchemail,
334
                    from        => $library->branchemail,
335
                    reply_to => $library->branchreplyto,
335
                    reply_to    => $library->branchreplyto,
336
                    sender   => $library->branchreturnpath,
336
                    sender      => $library->branchreturnpath,
337
                    subject  => "" . $letter->{title},
337
                    subject     => "" . $letter->{title},
338
                    template_id => $letter->{id},
338
                }
339
                }
339
            );
340
            );
340
341
Lines 486-493 sub SendAlerts { Link Here
486
                cc => join( ',', @cc ),
487
                cc => join( ',', @cc ),
487
                (
488
                (
488
                    (
489
                    (
489
                        C4::Context->preference("ClaimsBccCopy")
490
                        C4::Context->preference("ClaimsBccCopy") && ( $type eq 'claimacquisition'
490
                          && ( $type eq 'claimacquisition'
491
                            || $type eq 'claimissues' )
491
                            || $type eq 'claimissues' )
492
                    )
492
                    )
493
                    ? ( bcc => $userenv->{emailaddress} )
493
                    ? ( bcc => $userenv->{emailaddress} )
Lines 510-516 sub SendAlerts { Link Here
510
                        : ()
510
                        : ()
511
                    )
511
                    )
512
                ),
512
                ),
513
                subject => "" . $letter->{title},
513
                subject     => "" . $letter->{title},
514
                template_id => $letter->{id},
514
            }
515
            }
515
        );
516
        );
516
517
Lines 1453-1459 sub _send_message_by_email { Link Here
1453
            from     => $from_address,
1454
            from     => $from_address,
1454
            reply_to => $message->{'reply_address'} || $branch_replyto,
1455
            reply_to => $message->{'reply_address'} || $branch_replyto,
1455
            sender   => $branch_returnpath,
1456
            sender   => $branch_returnpath,
1456
            subject  => "" . $message->{subject}
1457
            subject  => "" . $message->{subject},
1458
            (
1459
                $message->{letter_id}
1460
                ? ( template_id => $message->{letter_id} )
1461
                : ()
1462
            ),
1463
            message_id => $message->{id}
1457
        };
1464
        };
1458
1465
1459
        if ( $message->{'content_type'} && $message->{'content_type'} eq SERIALIZED_EMAIL_CONTENT_TYPE ) {
1466
        if ( $message->{'content_type'} && $message->{'content_type'} eq SERIALIZED_EMAIL_CONTENT_TYPE ) {
Lines 1464-1471 sub _send_message_by_email { Link Here
1464
            $email->create($params);
1471
            $email->create($params);
1465
        } else {
1472
        } else {
1466
            $email = Koha::Email->create($params);
1473
            $email = Koha::Email->create($params);
1467
            $email->header('X-Koha-Letter-Id', $message->{letter_id} );
1468
            $email->header('X-Koha-Message-Id', $message->{id} );
1469
            if ($is_html) {
1474
            if ($is_html) {
1470
                $email->html_body( _wrap_html( $content, $subject ) );
1475
                $email->html_body( _wrap_html( $content, $subject ) );
1471
            } else {
1476
            } else {
(-)a/Koha/Email.pm (-1 / +5 lines)
Lines 173-183 sub create { Link Here
173
    $email->header( 'Reply-To', $addresses->{reply_to} )
173
    $email->header( 'Reply-To', $addresses->{reply_to} )
174
        if $addresses->{reply_to};
174
        if $addresses->{reply_to};
175
175
176
    $email->header( 'Sender'       => $addresses->{sender} ) if $addresses->{sender};
176
    $email->header( 'Sender'       => $addresses->{sender} )   if $addresses->{sender};
177
    $email->header( 'Content-Type' => $params->{contenttype} ) if $params->{contenttype};
177
    $email->header( 'Content-Type' => $params->{contenttype} ) if $params->{contenttype};
178
    $email->header( 'X-Mailer'     => "Koha" );
178
    $email->header( 'X-Mailer'     => "Koha" );
179
    $email->header( 'Message-ID'   => Email::MessageID->new->in_brackets );
179
    $email->header( 'Message-ID'   => Email::MessageID->new->in_brackets );
180
180
181
    # Add Koha message headers to aid later message identification
182
    $email->header( 'X-Koha-Template-Id' => $params->{template_id} ) if $params->{template_id};
183
    $email->header( 'X-Koha-Message-Id'  => $params->{message_id} )  if $params->{message_id};
184
181
    if ( $params->{text_body} ) {
185
    if ( $params->{text_body} ) {
182
        $email->text_body( $params->{text_body}, %{ $params->{body_params} } );
186
        $email->text_body( $params->{text_body}, %{ $params->{body_params} } );
183
    }
187
    }
(-)a/t/Koha/Email.t (-2 / +5 lines)
Lines 28-34 use_ok('Koha::Email'); Link Here
28
28
29
subtest 'create() tests' => sub {
29
subtest 'create() tests' => sub {
30
30
31
    plan tests => 25;
31
    plan tests => 27;
32
32
33
    t::lib::Mocks::mock_preference( 'SendAllEmailsTo', undef );
33
    t::lib::Mocks::mock_preference( 'SendAllEmailsTo', undef );
34
34
Lines 46-51 subtest 'create() tests' => sub { Link Here
46
            subject     => 'Some subject',
46
            subject     => 'Some subject',
47
            html_body   => $html_body,
47
            html_body   => $html_body,
48
            body_params => { charset => 'iso-8859-1' },
48
            body_params => { charset => 'iso-8859-1' },
49
            template_id => 1,
50
            message_id  => 1,
49
        }
51
        }
50
    );
52
    );
51
53
Lines 57-62 subtest 'create() tests' => sub { Link Here
57
    is( $email->email->header('Sender'), 'sender@example.com', 'Value set correctly' );
59
    is( $email->email->header('Sender'), 'sender@example.com', 'Value set correctly' );
58
    is( $email->email->header('Subject'), 'Some subject', 'Value set correctly' );
60
    is( $email->email->header('Subject'), 'Some subject', 'Value set correctly' );
59
    is( $email->email->header('X-Mailer'), 'Koha', 'Value set correctly' );
61
    is( $email->email->header('X-Mailer'), 'Koha', 'Value set correctly' );
62
    is( $email->email->header('X-Koha-Template-Id'), 1, 'Value set correctly' );
63
    is( $email->email->header('X-Koha-Message-Id'),  1, 'Value set correctly' );
60
    is( $email->email->body, $html_body, "Body set correctly" );
64
    is( $email->email->body, $html_body, "Body set correctly" );
61
    like( $email->email->content_type, qr|text/html|, "Content type set correctly");
65
    like( $email->email->content_type, qr|text/html|, "Content type set correctly");
62
    like( $email->email->content_type, qr|charset="?iso-8859-1"?|, "Charset set correctly");
66
    like( $email->email->content_type, qr|charset="?iso-8859-1"?|, "Charset set correctly");
63
- 

Return to bug 31627