~ubuntu-branches/debian/squeeze/sympa/squeeze

« back to all changes in this revision

Viewing changes to src/smtp.pm

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Hornburg (Racke)
  • Date: 2005-04-09 23:33:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050409233335-fm1lfafyokbq4bsx
Tags: 4.1.5-2

* added /etc/mail to directory list (Closes: #298404, thanks to Massimo
  Cetra <mcetra@navynet.it> for the report)
* fixed typo in package description (Closes: #300038, thanks to Florian
  Zumbiehl <florz@gmx.de> for the report) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# smtp.pm - This module does the SMTP job, it does send messages
2
 
# RCS Identication ; $Revision: 1.16.2.1 $ ; $Date: 2003/04/29 09:34:26 $ 
 
2
# RCS Identication ; $Revision: 1.23 $ ; $Date: 2004/01/15 16:25:03 $ 
3
3
#
4
4
# Sympa - SYsteme de Multi-Postage Automatique
5
5
# Copyright (c) 1997, 1998, 1999, 2000, 2001 Comite Reseau des Universites
32
32
use strict;
33
33
 
34
34
## RCS identification.
35
 
#my $id = '@(#)$Id: smtp.pm,v 1.16.2.1 2003/04/29 09:34:26 salaun Exp $';
 
35
#my $id = '@(#)$Id: smtp.pm,v 1.23 2004/01/15 16:25:03 salaun Exp $';
36
36
 
37
37
my $opensmtp = 0;
38
38
my $fh = 'fh0000000000';        ## File handle for the stream.
136
136
       } else {
137
137
           $str .= join(' ', @$rcpt);
138
138
       }
139
 
       do_log('debug3', $str);
 
139
       do_log('notice', $str);
140
140
   }
141
141
   close(IN);
142
142
   $opensmtp++;
191
191
        close SMTP;
192
192
        return 1;
193
193
    }else{    
194
 
        my $param = {'from' => "$from",
195
 
                     'email' => "$rcpt"
196
 
                     };   
197
 
 
198
 
        my $filename;
199
 
        if (-r "x509-user-cert-missing.tpl") {
200
 
            $filename = "x509-user-cert-missing.tpl";
201
 
        }elsif (-r "$Conf{'etc'}/templates/x509-user-cert-missing.tpl") {
202
 
            $filename = "$Conf{'etc'}/templates/x509-user-cert-missing.tpl";
203
 
        }elsif (-r "--ETCBINDIR--/templates/x509-user-cert-missing.tpl") {
204
 
            $filename = "--ETCBINDIR--/templates/x509-user-cert-missing.tpl";
205
 
        }else {
206
 
            # $filename = '';
207
 
            do_log ('err',"Unable to open file x509-user-cert-missing.tpl in list directory NOR $Conf{'etc'}/templates/x509-user-cert-missing.tpl NOR --ETCBINDIR--/templates/x509-user-cert-missing.tpl");
208
 
            return undef;
209
 
        }
210
 
    
211
 
        ## Should provide the $robot ; too many changes
212
 
        &mail::mailfile ($filename, $rcpt, $param, '', 'none');
213
 
 
214
194
        return undef;
215
195
    }
216
196
}
217
197
 
218
198
sub mailto {
219
 
   my($msg, $from, $encrypt, $originalfile , @rcpt) = @_;
220
 
   do_log('debug2', 'smtp::mailto(from: %s, %s, %d rcpt)', $from, $encrypt, $#rcpt);
 
199
   my($message, $from, @rcpt) = @_;
 
200
   do_log('debug2', 'smtp::mailto(from: %s, , file:%s, %s, %d rcpt)', $from, $message->{'filename'}, $message->{'smime_crypted'}, $#rcpt+1);
221
201
 
222
202
   my($i, $j, $nrcpt, $size, @sendto);
223
203
   my $numsmtp = 0;
226
206
   ## Extract body from original file to preserve signature
227
207
   my ($msg_body, $msg_header);
228
208
 
229
 
   $msg_header = $msg->head;
230
 
 
231
 
   if ($originalfile eq '_ALTERED_') {
232
 
       $msg_body = $msg->body_as_string;
233
 
 
234
 
   }elsif (ref($originalfile)) {
235
 
       $msg_body = $$originalfile;
236
 
 
 
209
   $msg_header = $message->{'msg'}->head;
 
210
 
 
211
   if ($message->{'altered'}) {
 
212
       $msg_body = $message->{'msg'}->body_as_string;
 
213
       
 
214
   }elsif ($message->{'smime_crypted'}) {
 
215
       $msg_body = ${$message->{'msg_as_string'}};
 
216
       
237
217
   }else {
238
 
   ## Get body from original file
239
 
       unless (open MSG, $originalfile) {
240
 
           do_log ('notice',"unable to open %s:%s",$originalfile,$!);
241
 
           last;
 
218
       ## Get body from original file
 
219
       unless (open MSG, $message->{'filename'}) {
 
220
           do_log ('notice',"Unable to open %s:%s",$message->{'filename'},$!);
 
221
           return undef;
242
222
       }
243
223
       my $in_header = 1 ;
244
224
       while (<MSG>) {
252
232
   }
253
233
   
254
234
   ## if the message must be crypted,  we need to send it using one smtp session for each rcpt
255
 
   if ($encrypt eq 'smime_crypted'){
 
235
   if ($message->{'smime_crypted'}){
256
236
       $numsmtp = 0;
257
 
       while ($i = shift(@rcpt)) {
258
 
           &sendto($msg_header, $msg_body, $from, [$i], $encrypt);
 
237
       while (defined ($i = shift(@rcpt))) {
 
238
           &sendto($msg_header, $msg_body, $from, [$i], $message->{'smime_crypted'});
259
239
           $numsmtp++
260
240
           }
261
241
       
262
242
       return ($numsmtp);
263
243
   }
264
244
 
265
 
   while ($i = shift(@rcpt)) {
 
245
   while (defined ($i = shift(@rcpt))) {
266
246
       my @k = reverse(split(/[\.@]/, $i));
267
247
       my @l = reverse(split(/[\.@]/, $j));
268
248
       if ($j && $#sendto >= $Conf{'avg'} && lc("$k[0] $k[1]") ne lc("$l[0] $l[1]")) {