17.3. Sending Multiple Mails per SMTP Connection
Anterior | Capítulo 17. Zend_Mail | Próxima

## 17.3. Sending Multiple Mails per SMTP Connection

By default, an SMTP connection is established for every e-mail that is sent. If you want to send multiple e-mails through one SMTP connection, you can handle the `connect()` yourself. If the transport has already established a connection before `send()` is called, it will be used and will not be closed:

Exemplo 17.3. Sending Multiple Mails per SMTP Connection

    <?php
    require_once 'Zend/Mail.php';
    $mail = new Zend_Mail();
    // build message...
    require_once 'Zend/Mail/Transport/Smtp.php';
    $tr = new Zend_Mail_Transport_Smtp('mail.example.com');
    Zend_Mail::setDefaultTransport($tr);
    $tr->connect();
    for ($i = 0; $i < 5; $i++) {
    $mail->send();
    }
    $tr->disconnect();
    ?>

Anterior | Acima | Próxima
17.2. Sending via SMTP | Principal | 17.4. Using Different Transports