Changeset 785


Ignore:
Timestamp:
02/02/10 18:29:52 (14 years ago)
Author:
nanardon
Message:
  • new feature: if expire_summary_to default config value is set, a summary of account expiration is sent to this address
File:
1 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts/lib/LATMOS/Accounts/Maintenance.pm

    r776 r785  
    112112            next; 
    113113        }; 
     114        my $mailcc = join(', ', @cc) || ''; 
     115        push(@summary, sprintf("%-15s %-10s %s\n  CC: %s\n", 
     116                $user->{obj}->id, 
     117                $user->{delay}, 
     118                $to || 'Not sent, no destination', 
     119                ($mailcc ? "  $mailcc\n" : ''), 
     120            ) 
     121        ); 
    114122        my $message; 
    115123        $template->process('account_expire.mail', $user, \$message) 
     
    120128            }; 
    121129 
    122         if ($options{test}) { 
    123             la_log(LA_NOTICE, 
    124                 "Expiration mail normally for %s (%s) would be sent to %s; cc %s", 
    125                 $user->{obj}->id, 
    126                 $user->{delay}, 
    127                 $to, (join(', ', @cc) || ''), 
    128             ); 
    129             if ($options{to}) { 
    130                 la_log(LA_NOTICE,"\tbut sent to %s", $mail{to}); 
    131             } 
    132         } else { 
     130        if (!$options{test}) { 
    133131            if (Mail::Sendmail::sendmail( 
    134132                    %mail, 
     
    148146    } 
    149147 
     148    if (@summary) { 
     149        if ($options{test}) { 
     150            print join('', @summary); 
     151        } else { 
     152            if ($self->val('_default_', 'expire_summary_to')) { 
     153                my %mail = ( 
     154                    From => $self->val('_default_', 'mailFrom', 'nomail@localhost'), 
     155                    Subject => 'LATMOS account expiration summary', 
     156                    smtp => $self->val('_default_', 'smtp'), 
     157                    'Content-Type' => 'text/plain; charset=utf-8', 
     158                    'X-LATMOS-Accounts' => '$Rev$', 
     159                    'X-LATMOS-Reason' => 'Account expiration', 
     160                    To => $self->val('_default_', 'expire_summary_to'), 
     161                ); 
     162                if (Mail::Sendmail::sendmail( 
     163                        %mail, 
     164                        Message => join('', @summary), 
     165                    )) { 
     166                    la_log(LA_NOTICE, "Expiration summary mail sent to %s", 
     167                        $self->val('_default_', 'expire_summary_to'), 
     168                    ); 
     169                } else { 
     170                    la_log(LA_ERR, "Cannot send mail: %s", $Mail::Sendmail::error); 
     171                } 
     172            } 
     173        } 
     174    } 
     175 
    150176    1; 
    151177} 
Note: See TracChangeset for help on using the changeset viewer.