src/Loggers/SwiftMailer/SmtpTransportMailerFactory.php
/**
     * Creates a new swift mailer instance based on the passed transport configuration.
     *
     * @param \TechDivision\Import\Configuration\SwiftMailer\TransportConfigurationInterface $transportConfiguration The mailer configuration
     *
     * @return \Swift_Mailer The mailer instance
     */
Creates a new swift mailer instance based on the passed transport configuration.

@return \Swift_Mailer The mailer instance
Creates a new swift mailer instance based on the passed transport configuration . @return \ Swift_Mailer The mailer instance
public function factory(TransportConfigurationInterface $transportConfiguration)
    {
        $smtpHost = null;
        if ($transportConfiguration->hasParam(SwiftMailerKeys::SMTP_HOST)) {
            $smtpHost = $transportConfiguration->getParam(SwiftMailerKeys::SMTP_HOST);
        }
        $smtpPort = null;
        if ($transportConfiguration->hasParam(SwiftMailerKeys::SMTP_PORT)) {
            $smtpPort = $transportConfiguration->getParam(SwiftMailerKeys::SMTP_PORT);
        }
        $smtpSecurity = null;
        if ($transportConfiguration->hasParam(SwiftMailerKeys::SMTP_SECURITY)) {
            $smtpSecurity = $transportConfiguration->getParam(SwiftMailerKeys::SMTP_SECURITY);
        }
        $transport = \Swift_SmtpTransport::newInstance($smtpHost, $smtpPort, $smtpSecurity);
        if ($transportConfiguration->hasParam(SwiftMailerKeys::SMTP_AUTH_MODE)) {
            $transport->setAuthMode($transportConfiguration->getParam(SwiftMailerKeys::SMTP_AUTH_MODE));
            $transport->setStreamOptions(
                array(
                    'ssl' => array(
                        'allow_self_signed' => true,
                        'verify_peer'       => false
                    )
                )
            );
            if ($transportConfiguration->hasParam(SwiftMailerKeys::SMTP_USERNAME)) {
                $transport->setUsername($transportConfiguration->getParam(SwiftMailerKeys::SMTP_USERNAME));
            }
            if ($transportConfiguration->hasParam(SwiftMailerKeys::SMTP_PASSWORD)) {
                $transport->setPassword($transportConfiguration->getParam(SwiftMailerKeys::SMTP_PASSWORD));
            }
        }
        return \Swift_Mailer::newInstance($transport);
    }
public function factory ( TransportConfigurationInterface $ transportConfiguration ) { $ smtpHost = null ; if ( $ transportConfiguration -> hasParam ( SwiftMailerKeys :: SMTP_HOST ) ) { $ smtpHost = $ transportConfiguration -> getParam ( SwiftMailerKeys :: SMTP_HOST ) ; } $ smtpPort = null ; if ( $ transportConfiguration -> hasParam ( SwiftMailerKeys :: SMTP_PORT ) ) { $ smtpPort = $ transportConfiguration -> getParam ( SwiftMailerKeys :: SMTP_PORT ) ; } $ smtpSecurity = null ; if ( $ transportConfiguration -> hasParam ( SwiftMailerKeys :: SMTP_SECURITY ) ) { $ smtpSecurity = $ transportConfiguration -> getParam ( SwiftMailerKeys :: SMTP_SECURITY ) ; } $ transport = \ Swift_SmtpTransport :: newInstance ( $ smtpHost , $ smtpPort , $ smtpSecurity ) ; if ( $ transportConfiguration -> hasParam ( SwiftMailerKeys :: SMTP_AUTH_MODE ) ) { $ transport -> setAuthMode ( $ transportConfiguration -> getParam ( SwiftMailerKeys :: SMTP_AUTH_MODE ) ) ; $ transport -> setStreamOptions ( array ( 'ssl' => array ( 'allow_self_signed' => true , 'verify_peer' => false ) ) ) ; if ( $ transportConfiguration -> hasParam ( SwiftMailerKeys :: SMTP_USERNAME ) ) { $ transport -> setUsername ( $ transportConfiguration -> getParam ( SwiftMailerKeys :: SMTP_USERNAME ) ) ; } if ( $ transportConfiguration -> hasParam ( SwiftMailerKeys :: SMTP_PASSWORD ) ) { $ transport -> setPassword ( $ transportConfiguration -> getParam ( SwiftMailerKeys :: SMTP_PASSWORD ) ) ; } } return \ Swift_Mailer :: newInstance ( $ transport ) ; }
Creates a new swift mailer instance based on the passed transport configuration.
Creates a new swift mailer instance based on the passed transport configuration .
// load the SMTP host from the configuration // load the SMTP port from the configuration // load the SMTP security from the configuration // initialize and create the mailer transport instance // query whether or not if a SMTP authentication mode has been specified // load the authentication mode from the configuration // set the stream context options, e. g. to allow self signed certificates // load the SMTP username from the configuration // load the SMTP password from the configuration // initialize, create and return the swift mailer instance