| Lines 279-298
          sub SendAlerts {
      
      
        Link Here | 
        
          | 279 |             my $innerletter = $letter; | 279 |             my $innerletter = $letter; | 
        
          | 280 |             my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'}); | 280 |             my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'}); | 
        
          | 281 |             parseletter( $innerletter, 'borrowers', $_->{'borrowernumber'} ); | 281 |             parseletter( $innerletter, 'borrowers', $_->{'borrowernumber'} ); | 
            
              |  |  | 282 |             $innerletter->{'content-type'} = 'text/plain; charset="utf8"'; | 
        
          | 282 |  | 283 |  | 
        
          | 283 |             # ... then send mail | 284 |             # ... then send mail | 
          
            
              | 284 |             if ( $borinfo->{email} ) { | 285 |             my %mail = ( | 
            
              | 285 |                 my %mail = ( | 286 |                 borrowernumber         => $borinfo->{borrowernumber}, | 
            
              | 286 |                     To      => $borinfo->{email}, | 287 |                 message_transport_type => 'email', | 
            
              | 287 |                     From    => $borinfo->{email}, | 288 |                 letter                 => $innerletter, | 
            
              | 288 |                     Subject => "" . $innerletter->{title}, | 289 |                 no_local_bcc           => 1, | 
            
              | 289 |                     Message => "" . $innerletter->{content}, | 290 |             ); | 
            
              | 290 |                     'Content-Type' => 'text/plain; charset="utf8"', | 291 |             EnqueueLetter( \%mail ); | 
            
              | 291 |                     ); |  |  | 
            
              | 292 |                 sendmail(%mail) or carp $Mail::Sendmail::error; | 
        
          | 293 |  | 292 |  | 
        
          | 294 | # warn "sending to $mail{To} From $mail{From} subj $mail{Subject} Mess $mail{Message}"; | 293 | # warn "sending to $mail{To} From $mail{From} subj $mail{Subject} Mess $mail{Message}"; | 
            
              | 295 |             } |  |  | 
        
          | 296 |         } | 294 |         } | 
        
          | 297 |     } | 295 |     } | 
        
          | 298 |     elsif ( $type eq 'claimacquisition' ) { | 296 |     elsif ( $type eq 'claimacquisition' ) { | 
  
    | Lines 335-358
          sub SendAlerts {
      
      
        Link Here | 
        
          | 335 |         } | 333 |         } | 
        
          | 336 |         $letter->{content} =~ s/<<[^>]*>>//g; | 334 |         $letter->{content} =~ s/<<[^>]*>>//g; | 
        
          | 337 |         my $innerletter = $letter; | 335 |         my $innerletter = $letter; | 
          
            
              | 338 |  | 336 |         $innerletter->{'content-type'} = 'text/plain; charset="utf8"'; | 
        
          | 339 |         # ... then send mail | 337 |         # ... then send mail | 
        
          | 340 |         if (   $databookseller->{bookselleremail} | 338 |         if (   $databookseller->{bookselleremail} | 
        
          | 341 |             || $databookseller->{contemail} ) | 339 |             || $databookseller->{contemail} ) | 
        
          | 342 |         { | 340 |         { | 
        
          | 343 |             my %mail = ( | 341 |             my %mail = ( | 
          
            
              | 344 |                 To => $databookseller->{bookselleremail} | 342 |                 to_address => $databookseller->{bookselleremail} | 
        
          | 345 |                   . ( | 343 |                   . ( | 
        
          | 346 |                     $databookseller->{contemail} | 344 |                     $databookseller->{contemail} | 
        
          | 347 |                     ? "," . $databookseller->{contemail} | 345 |                     ? "," . $databookseller->{contemail} | 
        
          | 348 |                     : "" | 346 |                     : "" | 
        
          | 349 |                   ), | 347 |                   ), | 
          
            
              | 350 |                 From           => $userenv->{emailaddress}, | 348 |                 from_address           => $userenv->{emailaddress}, | 
            
              | 351 |                 Subject        => "" . $innerletter->{title}, | 349 |                 message_transport_type => 'email', | 
            
              | 352 |                 Message        => "" . $innerletter->{content}, | 350 |                 letter                 => $innerletter, | 
            
              | 353 |                 'Content-Type' => 'text/plain; charset="utf8"', | 351 |                 no_local_bcc           => 1, | 
        
          | 354 |             ); | 352 |             ); | 
          
            
              | 355 |             sendmail(%mail) or carp $Mail::Sendmail::error; | 353 |             EnqueueLetter( \%mail ); | 
        
          | 356 |         } | 354 |         } | 
        
          | 357 |         if ( C4::Context->preference("LetterLog") ) { | 355 |         if ( C4::Context->preference("LetterLog") ) { | 
        
          | 358 |             logaction( | 356 |             logaction( | 
  
    | Lines 422-436
          sub SendAlerts {
      
      
        Link Here | 
        
          | 422 |             my $mail_msg  = $innerletter->{content}; | 420 |             my $mail_msg  = $innerletter->{content}; | 
        
          | 423 |             $mail_msg  ||= q{}; | 421 |             $mail_msg  ||= q{}; | 
        
          | 424 |             $mail_subj ||= q{}; | 422 |             $mail_subj ||= q{}; | 
          
            
              | 425 |  | 423 |             my $letter = { | 
            
              |  |  | 424 |             	title => $mail_subj, | 
            
              | 425 |             	content => $mail_msg, | 
            
              | 426 |             	'content-type' => 'text/plain; charset="utf8"', | 
            
              | 427 |             }; | 
        
          | 426 |             my %mail = ( | 428 |             my %mail = ( | 
          
            
              | 427 |                 To => $mail_to, | 429 |                 to_address             => $mail_to, | 
            
              | 428 |                 From    => $userenv->{emailaddress}, | 430 |                 from_address           => $userenv->{emailaddress}, | 
            
              | 429 |                 Subject => $mail_subj, | 431 |                 message_transport_type => 'email', | 
            
              | 430 |                 Message => $mail_msg, | 432 |                 letter                 => $letter, | 
            
              | 431 |                 'Content-Type' => 'text/plain; charset="utf8"', | 433 |                 no_local_bcc           => 1, | 
        
          | 432 |             ); | 434 |             ); | 
          
            
              | 433 |             sendmail(%mail) or carp $Mail::Sendmail::error; | 435 |             EnqueueLetter( \%mail ); | 
        
          | 434 |             logaction( | 436 |             logaction( | 
        
          | 435 |                 "ACQUISITION", | 437 |                 "ACQUISITION", | 
        
          | 436 |                 "CLAIM ISSUE", | 438 |                 "CLAIM ISSUE", | 
  
    | Lines 443-449
          sub SendAlerts {
      
      
        Link Here | 
        
          | 443 |                   . $innerletter->{content} | 445 |                   . $innerletter->{content} | 
        
          | 444 |             ) if C4::Context->preference("LetterLog"); | 446 |             ) if C4::Context->preference("LetterLog"); | 
        
          | 445 |         } | 447 |         } | 
          
            
              | 446 |     }     | 448 |     } | 
        
          | 447 |    # send an "account details" notice to a newly created user  | 449 |    # send an "account details" notice to a newly created user  | 
        
          | 448 |     elsif ( $type eq 'members' ) { | 450 |     elsif ( $type eq 'members' ) { | 
        
          | 449 |         # must parse the password special, before it's hashed. | 451 |         # must parse the password special, before it's hashed. | 
  
    | Lines 453-466
          sub SendAlerts {
      
      
        Link Here | 
        
          | 453 |         parseletter( $letter, 'branches', $externalid->{'branchcode'} ); | 455 |         parseletter( $letter, 'branches', $externalid->{'branchcode'} ); | 
        
          | 454 |  | 456 |  | 
        
          | 455 |         my $branchdetails = GetBranchDetail($externalid->{'branchcode'}); | 457 |         my $branchdetails = GetBranchDetail($externalid->{'branchcode'}); | 
            
              |  |  | 458 |         $letter->{'content-type'} = 'text/plain; charset="utf8"'; | 
            
              | 459 |  | 
        
          | 456 |         my %mail = ( | 460 |         my %mail = ( | 
          
            
              | 457 |                 To      =>     $externalid->{'emailaddr'}, | 461 |             to_address         => $externalid->{'emailaddr'}, | 
            
              | 458 |                 From    =>  $branchdetails->{'branchemail'} || C4::Context->preference("KohaAdminEmailAddress"), | 462 |             message_transport_type => 'email', | 
            
              | 459 |                 Subject => $letter->{'title'},  | 463 |             letter                 => $letter, | 
            
              | 460 |                 Message => $letter->{'content'}, | 464 |             no_local_bcc           => 1, | 
            
              | 461 |                 'Content-Type' => 'text/plain; charset="utf8"', |  |  | 
        
          | 462 |         ); | 465 |         ); | 
          
            
              | 463 |         sendmail(%mail) or carp $Mail::Sendmail::error; | 466 |         EnqueueLetter( \%mail ); | 
        
          | 464 |     } | 467 |     } | 
        
          | 465 | } | 468 | } | 
        
          | 466 |  | 469 |  | 
  
    | Lines 633-645
          sub EnqueueLetter ($) {
      
      
        Link Here | 
        
          | 633 |     # If we have any attachments we should encode then into the body. | 636 |     # If we have any attachments we should encode then into the body. | 
        
          | 634 |     if ( $params->{'attachments'} ) { | 637 |     if ( $params->{'attachments'} ) { | 
        
          | 635 |         $params->{'letter'} = _add_attachments( | 638 |         $params->{'letter'} = _add_attachments( | 
          
            
              | 636 |             {   letter      => $params->{'letter'}, | 639 |             { | 
            
              |  |  | 640 |                 letter      => $params->{'letter'}, | 
        
          | 637 |                 attachments => $params->{'attachments'}, | 641 |                 attachments => $params->{'attachments'}, | 
        
          | 638 |                 message     => MIME::Lite->new( Type => 'multipart/mixed' ), | 642 |                 message     => MIME::Lite->new( Type => 'multipart/mixed' ), | 
        
          | 639 |             } | 643 |             } | 
        
          | 640 |         ); | 644 |         ); | 
        
          | 641 |     } | 645 |     } | 
        
          | 642 |  | 646 |  | 
            
              |  |  | 647 |     # If we aren't given a from address, we first go for the user's | 
            
              | 648 |     # branch (which may be the librarians, but that's OK) email, if that doesn't | 
            
              | 649 |     # work, we go for the koha admin address. | 
            
              | 650 |     if ( !$params->{'from_address'} ) { | 
            
              | 651 |         my $userenv       = C4::Context->userenv; | 
            
              | 652 |         my $branch        = $userenv->{branch}; | 
            
              | 653 |         my $branch_detail = GetBranchDetail($branch); | 
            
              | 654 |         my $branch_email  = $branch_detail->{branchemail}; | 
            
              | 655 |         $params->{from_address} = $branch_email | 
            
              | 656 |           || C4::Context->preference('KohaAdminEmailAddress'); | 
            
              | 657 |     } | 
            
              | 658 |  | 
            
              | 659 |     # Set a reply-to if there isn't one already. | 
            
              | 660 |     $params->{'reply_to_address'} = $params->{from_address} | 
            
              | 661 |       if !$params->{reply_to_address}; | 
            
              | 662 |  | 
        
          | 643 |     my $dbh       = C4::Context->dbh(); | 663 |     my $dbh       = C4::Context->dbh(); | 
        
          | 644 |     my $statement = << 'ENDSQL'; | 664 |     my $statement = << 'ENDSQL'; | 
        
          | 645 | INSERT INTO message_queue | 665 | INSERT INTO message_queue | 
  
    | Lines 652-660
          ENDSQL
      
      
        Link Here | 
        
          | 652 |  | 672 |  | 
        
          | 653 |     my $sth    = $dbh->prepare($statement); | 673 |     my $sth    = $dbh->prepare($statement); | 
        
          | 654 |     my $result = $sth->execute( | 674 |     my $result = $sth->execute( | 
          
            
              | 655 |         $params->{'borrowernumber'},                # borrowernumber | 675 |         $params->{'borrowernumber'},         # borrowernumber | 
            
              | 656 |         $params->{'letter'}->{'title'},             # subject | 676 |         $params->{'letter'}->{'title'},      # subject | 
            
              | 657 |         $params->{'letter'}->{'content'},           # content | 677 |         $params->{'letter'}->{'content'},    # content | 
        
          | 658 |         $params->{'letter'}->{'metadata'} || '',    # metadata | 678 |         $params->{'letter'}->{'metadata'} || '',    # metadata | 
        
          | 659 |         $params->{'letter'}->{'code'}     || '',    # letter_code | 679 |         $params->{'letter'}->{'code'}     || '',    # letter_code | 
        
          | 660 |         $params->{'letter'}->{'content-type'},      # content_type | 680 |         $params->{'letter'}->{'content-type'},      # content_type | 
            
              | 661 | -  |  |  |