Alternc  latest
Alternc logiel libre pour l'hébergement
sendmail
Go to the documentation of this file.
1 #!/usr/bin/perl
2 
3 # 1. On lit les en-têtes et on mémorise l'état.
4 
5 $fr="";
6 
7 $rt="";
8 
9 open(SM,"|/usr/sbin/sendmail -t -i -f '".@ARGV[0]."'");
10 
11 chomp($A=<STDIN>);
12 while ($A ne "") {
13  print SM $A."\n";
14  if ($A=~/^From:(.*)/i) {
15  $fr=$1;
16  }
17  if ($A=~/^Reply-to:(.*)/i) {
18  $rt=$1;
19  }
20  chomp($A=<STDIN>);
21 }
22 
23 $home=quotemeta $ENV{'ALTERNC_HTML'};
24 $ENV{'PWD'}=~/^$home\/.\/([^\/]*)/;
25 $user=$1;
26 
27 if (!$fr) {
28  if (!$rt) {
29  print SM "From: ".$user."\n";
30  } else {
31  print SM "From: $rt\n";
32  print SM "X-RealFrom: ".$user."\n";
33  }
34 } else {
35  if (!$rt) {
36  print SM "Reply-To: $fr\n";
37  }
38  print SM "X-RealFrom: ".$user."\n";
39 }
40 
41 # 3. On ajoute la fameuse ligne vide :)
42 print SM "\n";
43 # 4. Et on repasse la suite sans traitement (cat)
44 $A=<STDIN>;
45 while ($A) {
46  print SM $A;
47  $A=<STDIN>;
48 }
49 close SM;
50 
51 
52