[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MHonArc Development Status



Pleas see the attached files

mhonarc      ## Used to call my custom routine for post processing

mh_mha.pl    ## My custom routine for post processing 
             ##   it call the anti-virus software (uvscan) and send a
             ##   comfirmation e-mail (with the original message) back to the sender.

mhinit.pl    ## Declere a new vector %Auto_Sub = ();    # Campo Auto-Subimitted - ROBERTO 08/12/2000

mhamain.pl   ## Fill the vector %Auto_Sub whith the message field 'auto-submitted'
             ##   pass1: $auto_s=$fields{'auto-submitted'};
             ##   pass2: $Auto_Sub{$index} = $auto_s; #### Auto-Submitted: ROBERTO 08/12/2000

Search for ROBERTO in those files to find where I add those lines.

I hope you can easy understand it. If not, it is probably my fault and, please, let me know.

Thank you

Roberto

At 21:06 08/08/01, you wrote:
>On August 7, 2001 at 17:43, Roberto =?iso-8859-1?Q?Jo=E3o?= Lopes Garcia wrote:
>
>> I did same modifications to allow the message header field Auto-Submitted: to
>>  be accessible from the main file mhonarc.
>...
>> If you want I will send you the files I changed.
>
>Sure, since I am having a little trouble understanding exactly what you
>did and to see if what I plan for 2.5 can cover your usage case.  I
>plan to add some basic callback mechanisms to help facilitate custom
>processing, but how good it will probably depend on user needs.  Also,
>the code base for 2.x does make some extensibility hard to do.
>Hopefully, the callback mechanisms should provide you with what you
>need.
>
>--ewh 

-----------------------------------------------------------------
Eng. Roberto João Lopes Garcia        E-mail: roberto@mha.com.br 
F. 55 11 3747 7697   FAX  55 11 3747-7700

                MHA Engenharia Ltda     

E-mail: mha@mha.com.br    WWW: http://www.mha.com.br

Av Maria Coelho Aguiar, 215 Bloco D     2 Andar
Centro Empresarial de Sao Paulo
Sao Paulo - BRASIL - 05805 000
------------------------------------------------------------------

Attachment: mhamain.pl
Description: Binary data

Attachment: mhinit.pl
Description: Binary data

Attachment: mhonarc
Description: Binary data

#!/usr/bin/perl
use lib qw(/usr/lib/perl5/site_perl/5.005);
#!/usr/local/bin/perl
##
## mh_mha.pl - Roberto João Lopes Garcia -   ter dez  5 11:20:33 BRST 2000
##
##  Rotinas de pós processamento das mensagens convertidas pelo programa mhonarc
##
##  O programa  /usr/bin/mhonarc  deve ser alterado para chamar as rotinas
##  existentes nesse arquivo. Alteração como no exemplo abaixo
##
## MAIN: {
##     unshift(@INC, 'lib');	# Should I leave this line in?
##
##     require 'mhamain.pl' || die qq/ERROR: Unable to require "mhamain.pl"\n/;
##     mhonarc::initialize();
##     if(mhonarc::process_input()) {
##        require 'mh_mha.pl' || die qq/ERROR: Unable to require "mh_mha.pl"\n/;
##        mhonarc::mha_post();
##     }
##     else {
##        exit($mhonarc::CODE);
##     }
##
##  Um link simbólico deve ser feito com esse arquivo como abaixo
##
##  ln -s /home/httpd/html/mha_mail/m2html/mrc/mh_mha.pl  /usr/lib/perl5/site_perl/5.005/mh_mha.pl
##
##  ************ AS LINHAS ABAIXO DEVEM SER INSERIDAS NO ARQUIVO mhamain.pl  **********
##   *********** SUB read_mail_header() ANTES DE OBTER Get Msg-ID msgid
##
##     ##---------------------------------------------------------##
##    ## auto_s EXTERNA - ROBERTO sex dez  8 12:41:45 BRST 2000  ##
##    ##---------------------------------------------------------##
##    $auto_s=$fields{'auto-submitted'};
##
##
##  ************ AS LINHAS ABAIXO DEVEM SER INSERIDAS NO ARQUIVO mhamain.pl  **********
##   *********** SUB doit() TODA A VEZ, E ABAIXO DE:
##   *****	if ($index ne '') {
##   *****	    ($From{$index},$Date{$index},$Subject{$index}) =
##   *****		($from,$date,$sub);
##
## 	    $Auto_Sub{$index} = $auto_s; #### Auto-Submitted: ROBERTO 08/12/2000
##
##  ************ AS LINHAS ABAIXO DEVEM SER INSERIDAS NO ARQUIVO mhinit.pl  **********
##   *********** SABAIXO DE: %From   	= ();	# Message indexes to froms
##
##		%Auto_Sub   	= ();	# Campo Auto-Subimitted - ROBERTO 08/12/2000
##
package mhonarc;

sub t2s {
   my @wdays = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
   my @mons  = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');


   my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();

   eval { require POSIX; };
   $tz=POSIX::strftime("%z", $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);

   $yearfull = $year + 1900;
    $wd = $wdays[$wday];
    $m = $mons[$mon];
    $sec	= sprintf("%02d", $sec);
    $min	= sprintf("%02d", $min);
    $hour	= sprintf("%02d", $hour);
    $mday	= sprintf("%02d", $mday);
    $yearfull	= sprintf("%04d", $yearfull);

    $str=sprintf("%s, %s %s %s %s:%s:%s %s", $wd, $mday, $m, $yearfull, $hour, $min, $sec, $tz);
    ####print "Antes de sair da função: $str\n";
    return $str;
}

sub  mha_post {
   foreach $index (keys %mhonarc::AddIndex) {
      $subject = $mhonarc::Subject{$index};
      $from = $mhonarc::From{$index};
      $usr = $ENV{E_NAME};    ### ALTERAR DEPOIS PARA E_NAME APENAS
      $nm_usr = $ENV{E_USR};    ### NOME DO USUÁRIO
      $nrp = $usr;
      $nrp =~ s/prj//;
      $date = $mhonarc::Date{$index};
      $nr = $mhonarc::IndexNum{$index};
      $nr2 = &mhonarc::fmt_msgnum($nr);
      $msg = $mhonarc::Message{$index};
      $msg =~ s/<A HREF=\"$mhonarc::MsgPrefix$nr2\/.* BORDER=0 ALT=\"\">/Arquivo Convertido: /g; ### RETIRA LINKS DOS ARQUIVOS RECEBIDOS

      $fn = &mhonarc::msgnum_filename($nr);
      $addr = &mhonarc::extract_email_address($from);
      $nm = &mhonarc::extract_email_name($from);
      $nm =  &readmail::MAILdecode_1522_str($nm,0);
      ###print "From: $from Addr: $addr Nome: $nm\n\n";
      $auto = $Auto_Sub{$index};
      ###if(!defined($auto)) {  print "Auto Not Defined\n";}
      ###print "Auto: $auto\n\n";
      #$dt =  localtime;
      #$dt2 =  gmtime;
      #$dt3 =  getdate(time);
      #$dt4 =  time2str('%a, %d %b %Y %H:%M:%S -0000', time);
      $dt4=t2s;
      $id_msg = $Index2MsgId{$index};
      ###
      ### SE A MENSAGEM TEM O CAMPO Auto-Submitted NÃO ENVIA CONFIRMAÇÃO
      ###
      ##if(!defined($auto)) {
      ###if(!defined($auto) && $addr ne "$usr\@mha.com.br")
      ###open(ROB, ">$mhonarc::OUTDIR/rob.txt") || die("Nao pode abrir $mhonarc::OUTDIR/rob.txt: $!");
      $usr_addr=$usr . '@mha.com.br';
      ###print ROB "$addr    $usr_addr\n";
      ###close(ROB);
      if((!defined($auto)) && ($addr ne $usr_addr)) {
         open(RFR, ">$mhonarc::OUTDIR/$nr2.msg") || die("Nao pode abrir $mhonarc::OUTDIR/$nr2.msg: $!");
         ###$nr2print  RFR "sendmail $addr\n";
         #print  RFR "Date: $dt\n";
         #print  RFR "Date: $dt2\n";
         #print  RFR "Date: $dt3\n";
         ###print  RFR "Return-Path: <$usr\@mha.com.br>\n";
         print  RFR "X-Mailer: The 777ind - MHA Engenharia Ltda\n";
         print  RFR "X-Sender: $usr\@mha.com.br\n";
         print  RFR "Date: $dt4\n";
         print  RFR "To: $addr\n";
         print  RFR "From: $nm_usr <$usr\@mha.com.br>\n";
         print  RFR "Subject: Re: $subject [MHA $nrp/$nr2]\n";
         print  RFR "In-Reply-To: <$id_msg>\n";
         print  RFR "Auto-Submitted: Auto-Replied (Receiving-Confirmation)\n";
         print  RFR "Mime-Version: 1.0\n";
         print  RFR "Content-Type: multipart/mixed;\n";
         print  RFR "        boundary=\"=====================_The_777ind_20001205_$nrp\_$nr2==_\"\n\n";
         print  RFR "--=====================_The_777ind_20001205_$nrp\_$nr2==_\n";
         print  RFR "Content-Type: text/plain; charset=\"us-ascii\"; format=flowed\n\n";

         print  RFR "$nm,\n\n";
         print  RFR "*** Confirmação automática de recebimento de mensagem eletrônica - E-MAIL ***\n";
         print  RFR "             (Eletronic mail received - automatic confirmation)\n\n";

         print  RFR "Vossa mensagem foi recebida pelo Sistema de Recebimento de Mensagens da\n";
         print  RFR "MHA Engenharia Ltda e registrada sob o número:\n";
         print  RFR "(Your message was received by MHA Engenharia Ltda's Message Receiving System)\n";
         print  RFR "(It was registered as number:)";
         print  RFR "\n\n\t\t\t$nrp/$nr2\n\n";

         print  RFR "Essa mensagem foi gerada automaticamente, favor não responde-la.\n";
         print  RFR "(This message was automatically generated, please do not reply.)\n\n\n";

         print  RFR "--(Original message) Segue cópia da vossa mensagem original - $date --\n\n";

         print  RFR "--=====================_The_777ind_20001205_$nrp\_$nr2==_\n";
         print  RFR "Content-Type: text/html; charset=\"us-ascii\"\n\n";

         print  RFR "<blockquote type=cite class=cite cite=\"$addr\">\n";
         print  RFR "$msg";
         print  RFR "</blockquote>\n\n";

         print  RFR "--=====================_The_777ind_20001205_$nrp\_$nr2==_\n.\n";
         close(RFR) || die("Nao pode fechar $mhonarc::OUTDIR/$nr2.msg: $!");
         if (-e "$mhonarc::OUTDIR/$nr2.msg") {
            $resp= "/usr/bin/ssh  -l ?????? ?????? ?????? ????? ??????  \"sendmail $addr\" < $mhonarc::OUTDIR/$nr2.msg";
            ###print "Resp= $resp\n";
            system("$resp");
            ###print "Após o envio!\n";
         }
     }

     $msg_dir="$mhonarc::OUTDIR/$mhonarc::MsgPrefix$nr2";
     if (-d "$msg_dir") {
        ###print "Existe diretório $msg_dir! Verificando Virus ...\n";
        $cmd="/home/httpd/html/mha_mail/m2html/mrc/scan_drv.scr $msg_dir";
        system("$cmd"); ### && die("Nao pode executar system(): $!\n");
     }
     else {
        ###print "Não existe diretório $msg_dir!\n";
     }
   }
}
1;

[Index of Archives]     [Bugtraq]     [Yosemite News]     [Mhonarc Home]