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

(-)a/C4/Letters.pm (-50 lines)
Lines 529-584 sub SendAlerts { Link Here
529
                . $letter->{content}
529
                . $letter->{content}
530
        ) if C4::Context->preference("ClaimsLog");
530
        ) if C4::Context->preference("ClaimsLog");
531
    }
531
    }
532
   # send an "account details" notice to a newly created user
533
    elsif ( $type eq 'members' ) {
534
        my $library = Koha::Libraries->find( $externalid->{branchcode} );
535
        my $letter = GetPreparedLetter (
536
            module => 'members',
537
            letter_code => $letter_code,
538
            branchcode => $externalid->{'branchcode'},
539
            lang       => $externalid->{lang} || 'default',
540
            tables => {
541
                'branches'    => $library->unblessed,
542
                'borrowers' => $externalid->{'borrowernumber'},
543
            },
544
            substitute => { 'borrowers.password' => $externalid->{'password'} },
545
            want_librarian => 1,
546
        ) or return;
547
        return { error => "no_email" } unless $externalid->{'emailaddr'};
548
549
        my $success = try {
550
551
            # FIXME: This 'default' behaviour should be moved to Koha::Email
552
            my $mail = Koha::Email->create(
553
                {
554
                    to       => $externalid->{'emailaddr'},
555
                    from     => $library->branchemail,
556
                    reply_to => $library->branchreplyto,
557
                    sender   => $library->branchreturnpath,
558
                    subject  => "" . $letter->{'title'},
559
                }
560
            );
561
562
            if ( $letter->{is_html} ) {
563
                $mail->html_body( _wrap_html( $letter->{content}, "" . $letter->{title} ) );
564
            }
565
            else {
566
                $mail->text_body( $letter->{content} );
567
            }
568
569
            $mail->send_or_die({ transport => $library->smtp_server->transport });
570
        }
571
        catch {
572
            # We expect ref($_) eq 'Email::Sender::Failure'
573
            $error = $_->message;
574
575
            carp "$_";
576
            return;
577
        };
578
579
        return { error => $error }
580
            unless $success;
581
    }
582
532
583
    # If we come here, return an OK status
533
    # If we come here, return an OK status
584
    return 1;
534
    return 1;
(-)a/members/memberentry.pl (-8 / +22 lines)
Lines 481-494 if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ Link Here
481
                $newdata{emailaddr} = $emailaddr;
481
                $newdata{emailaddr} = $emailaddr;
482
                my $err;
482
                my $err;
483
                eval {
483
                eval {
484
                    $err = SendAlerts ( 'members', \%newdata, "ACCTDETAILS" );
484
                    my $letter = GetPreparedLetter(
485
                        module      => 'members',
486
                        letter_code => 'ACCTDETAILS',
487
                        branchcode  => $patron->branchcode,,
488
                        lang        => $patron->lang || 'default',
489
                        tables      => {
490
                            'branches'  => $patron->branchcode,
491
                            'borrowers' => $patron->borrowernumber,
492
                        },
493
                        want_librarian => 1,
494
                    ) or return;
495
496
                    my $success = EnqueueLetter(
497
                        {
498
                            letter                 => $letter,
499
                            borrowernumber         => $patron->id,
500
                            to_address             => $emailaddr,
501
                            message_transport_type => 'email'
502
                        }
503
                    );
485
                };
504
                };
486
                if ( $@ ) {
505
                if ($@) {
487
                    $template->param(error_alert => $@);
506
                    $template->param( error_alert => $@ );
488
                } elsif ( ref($err) eq "HASH" && defined $err->{error} and $err->{error} eq "no_email" ) {
489
                    $template->{VARS}->{'error_alert'} = "no_email";
490
                } else {
491
                    $template->{VARS}->{'info_alert'} = 1;
492
                }
507
                }
493
            }
508
            }
494
        }
509
        }
495
- 

Return to bug 17648