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 $
4
4
# Sympa - SYsteme de Multi-Postage Automatique
5
5
# Copyright (c) 1997, 1998, 1999, 2000, 2001 Comite Reseau des Universites
194
my $param = {'from' => "$from",
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";
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");
211
## Should provide the $robot ; too many changes
212
&mail::mailfile ($filename, $rcpt, $param, '', 'none');
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);
222
202
my($i, $j, $nrcpt, $size, @sendto);
226
206
## Extract body from original file to preserve signature
227
207
my ($msg_body, $msg_header);
229
$msg_header = $msg->head;
231
if ($originalfile eq '_ALTERED_') {
232
$msg_body = $msg->body_as_string;
234
}elsif (ref($originalfile)) {
235
$msg_body = $$originalfile;
209
$msg_header = $message->{'msg'}->head;
211
if ($message->{'altered'}) {
212
$msg_body = $message->{'msg'}->body_as_string;
214
}elsif ($message->{'smime_crypted'}) {
215
$msg_body = ${$message->{'msg_as_string'}};
238
## Get body from original file
239
unless (open MSG, $originalfile) {
240
do_log ('notice',"unable to open %s:%s",$originalfile,$!);
218
## Get body from original file
219
unless (open MSG, $message->{'filename'}) {
220
do_log ('notice',"Unable to open %s:%s",$message->{'filename'},$!);
243
223
my $in_header = 1 ;
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'}){
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'});
262
242
return ($numsmtp);
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]")) {