Page 1 of 1

Understanding swift log

Posted: Thu Aug 21, 2008 10:29 am
by daneel
Hi, I'm using swift 3.3.2 and I'm using the logging function. Particulary I'm interested in this:

Code: Select all

 
>> MAIL FROM: <envio@bbg-mail.net>
<< 250 2.1.0 <envio@bbg-mail.net>... Sender ok
>> RCPT TO: <jmedrand@aasa.com.pe>
<< 250 2.1.5 <jmedrand@aasa.com.pe>... Recipient ok
>> DATA
<< 354 Enter mail, end with "." on a line by itself
>> <MESSAGE DATA>
>> 
.
<< 250 2.0.0 m4JLIuaE013080 Message accepted for delivery
++ Message sent to 1/1 recipients
>> QUIT
<< 221 2.0.0 smtp177.allytech.com closing connection
++ Closing down SMTP connection.
++ Closing down SMTP connection.++ Log level changed to 4
>> QUIT
<< 221 2.0.0 smtp177.allytech.com closing connection
++ Closing down SMTP connection.
++ Closing down SMTP connection.++ Log level changed to 4
>> QUIT
<< 221 2.0.0 smtp177.allytech.com closing connection
++ Closing down SMTP connection.
++ Closing down SMTP connection.++ Log level changed to 4
>> QUIT
<< 221 2.0.0 smtp177.allytech.com closing connection
++ Closing down SMTP connection.
++ Closing down SMTP connection.++ Log level changed to 4
>> QUIT
<< 221 2.0.0 smtp177.allytech.com closing connection
++ Closing down SMTP connection.
++ Closing down SMTP connection.++ Log level changed to 4
>> QUIT
 
You'll see that there are four lines that repeat a lot of times (a lot more in the real log file). What does that means ??

Thanks!

Re: Understanding swift log

Posted: Thu Aug 21, 2008 10:46 am
by ghurtado
Can you post the code?

Re: Understanding swift log

Posted: Thu Aug 21, 2008 12:04 pm
by daneel
Yeah, it's quite long, but I'm copying the central part:

Code: Select all

 
<?php
        $exit = false;
        /* @var $oNews Newsletter */
        foreach ($this->arrNewsletters as $oNews)
        {
            $this->log('Empieza Newsletter: ' . $oNews->getAsunto());
 
            //CREA EL MENSAJE
            $oMessage = NewsletterPeer::createMessage($oNews);
 
            $oLista = $oNews->getLista();
            $oLista->createTableMap();
 
            try {
                $oLista->getPDOConnection();
            } catch (Exception $ex) {
                $this->log($ex->getMessage());
                break;
            }
 
            $crit = new Criteria();
 
            if($oLista->getEslocal()) {
                $crit->add(SuscriptorPeer::$ACTIVO,true);
            }
 
            if($oNews->getIdfiltro()) {
                $crit = $oNews->getFiltro()->getCriteria();
            }
 
            try {
                $totalUsuarios = $oLista->doCountSuscriptores($crit);
 
                $procesados = $oNews->getEmailsprocesados() ? $oNews->getEmailsprocesados() : 0;
                $enviados = $oNews->getEmailsenviados();
                $errores = $oNews->getEmailserrores();
 
                $this->log('-Total: ' . $totalUsuarios . '/Procesados: ' . $procesados);
                $oNews->setEmailsTotal($totalUsuarios);
 
                while($procesados < $totalUsuarios && !$exit) {
 
                    try {
                        // ADICIONA TIEMPO PARA EL PROCESO
                        set_time_limit(30);
                        $crit->setOffset($procesados);
                        $crit->setLimit(self::EMAILS_SEND );
 
                        $arrUsuarios = $this->getSuscriptores($oNews,$oLista->getIdlista(),$crit);
                        $usuarios = count($arrUsuarios);
                        $this->log('--Usuarios Reales ' . $usuarios);
 
                        // REEMPLAZO DE CAMPOS
                        $oRecipients = NewsletterPeer::createRecipients($arrUsuarios);
                        $replacements = NewsletterPeer::makeReplacements($arrUsuarios,$oNews);
                        $this->oSwift->getPlugin('decorator')->setReplacements($replacements);
 
                        try {
                            $enviados += $this->oBacht->send($oMessage,$oRecipients,NewsletterPeer::createFromAddress($oNews),$oNews->getIdnewsletter());
                            $procesados += $usuarios;
 
                            $oNews->setEmailsenviados($enviados);
                            $oNews->setEmailsprocesados($procesados);
                            $oNews->save();
 
                        } catch (Exception $ex) {
                            $this->log($ex->getMessage());
                            $this->processBlocked();
                            $break = true;
                        }
 
 
                    } catch (PDOException $ex) {
                        $this->log($ex->getMessage());
                        $break = true;
 
                    }
                    catch (Exception $ex) {
                        $this->log($ex->getMessage());
                    }
 
                    // LIMPIA LA MEMORIA
                    unset($usuarios);
                    unset($arrUsuarios);
                    unset($oRecipients);
                    unset($plug);
                    SuscriptorPeer::clearInstancePool();
                    //FIN
 
                    //CONTROLA LA SALIDA
                    $exit = $this->controlTime();
                    if($break == true) $exit = true;
 
                }
 
                //GUARDA ENVIOS FALLIDOS
                $this->saveFailedRecipients($oNews);
 
                if($procesados >= $totalUsuarios) $oNews->setEnviada(true);
                $oNews->save();
 
                $this->log('Termina Newsletter ' . $oNews->getIDNewsletter());
            } catch (Exception  $ex) {
                $this->log('Error con newsletter ' . $oNews->getIDNewsletter());
            }
 
 
            //LIMIA MEMORIA
            unset($oMessage);
            unset($oNews);
            unset($oLista);
            //FIN
            // SALE SI SE TERMINO EL TIEMPO
            if($exit) break;
        }
 
        $this->oSwift->disconnect();
        unset($this->oSwift);
        unset($this->oBacht);
        file_put_contents('swift_log.txt',Swift_LogContainer::getLog()->dump(true),FILE_APPEND);
?>
 
This thing doesn't happen all the time... I just saw it now, checking the log... it appears like a lot, and then just goes on:

Code: Select all

 
<< 221 2.0.0 smtp177.allytech.com closing connection
++ Closing down SMTP connection.
++ Closing down SMTP connection.>> DATA
<< 354 Enter mail, end with "." on a line by itself
>> <MESSAGE DATA>
>> 
.
<< 250 2.0.0 m5IAwe3h000758 Message accepted for delivery
++ Message sent to 1/1 recipients
>> MAIL FROM: <envio@bbg-mail.net>
<< 250 2.1.0 <envio@bbg-mail.net>... Sender ok
>> RCPT TO: <andrea@mada.com.ar>
<< 250 2.1.5 <andrea@mada.com.ar>... Recipient ok
>> DATA
<< 354 Enter mail, end with "." on a line by itself
>> <MESSAGE DATA>
>> 
 

Re: Understanding swift log

Posted: Thu Aug 21, 2008 12:45 pm
by ghurtado
Is it because it is opening and closing an SMTP connection for each newsletter it sends?

Re: Understanding swift log

Posted: Fri Aug 22, 2008 4:17 pm
by daneel
Is it because it is opening and closing an SMTP connection for each newsletter it sends?
In my code, I use swift's bacht send for every 30 emails... so it should do that (open and close connection) every 30 emails,
not like 50 times like the log seems to reflect... and also, it doesn't always do that.

:banghead: