Understanding swift log

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
daneel
Forum Newbie
Posts: 19
Joined: Wed Apr 09, 2008 3:39 pm

Understanding swift log

Post 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!
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: Understanding swift log

Post by ghurtado »

Can you post the code?
daneel
Forum Newbie
Posts: 19
Joined: Wed Apr 09, 2008 3:39 pm

Re: Understanding swift log

Post 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>
>> 
 
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: Understanding swift log

Post by ghurtado »

Is it because it is opening and closing an SMTP connection for each newsletter it sends?
daneel
Forum Newbie
Posts: 19
Joined: Wed Apr 09, 2008 3:39 pm

Re: Understanding swift log

Post 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:
Post Reply