Create an instance of the SMTP Swift Transport driver.

@return \Swift_SmtpTransport
163209
protected function createSmtpDriver()
    {
        $config = $this->getTransportConfig();

        // The Swift SMTP transport instance will allow us to use any SMTP backend
        // for delivering mail such as Sendgrid, Amazon SES, or a custom server
        // a developer has available. We will just pass this configured host.
        $transport = new SmtpTransport($config['host'], $config['port']);

        if (isset($config['encryption'])) {
            $transport->setEncryption($config['encryption']);
        }

        // Once we have the transport we will check for the presence of a username
        // and password. If we have it we will set the credentials on the Swift
        // transporter instance so that we'll properly authenticate delivery.
        if (isset($config['username'])) {
            $transport->setUsername($config['username']);
            $transport->setPassword($this->getSecureConfig('password'));
        }

        // Next we will set any stream context options specified for the transport
        // and then return it. The option is not required any may not be inside
        // the configuration array at all so we'll verify that before adding.
        if (isset($config['stream'])) {
            $transport->setStreamOptions($config['stream']);
        }

        return $transport;
    }
489882
protected function registerSmtpTransport($config)
	{
		$this->app['swift.transport'] = $this->app->share(function($app) use ($config)
		{
			extract($config);

			// The Swift SMTP transport instance will allow us to use any SMTP backend
			// for delivering mail such as Sendgrid, Amazon SMS, or a custom server
			// a developer has available. We will just pass this configured host.
			$transport = SmtpTransport::newInstance($host, $port);

			if (isset($encryption))
			{
				$transport->setEncryption($encryption);
			}

			// Once we have the transport we will check for the presence of a username
			// and password. If we have it we will set the credentials on the Swift
			// transporter instance so that we'll properly authenticate delivery.
			if (isset($username))
			{
				$transport->setUsername($username);

				$transport->setPassword($password);
			}

			return $transport;
		});
	}
1089158
protected function createSmtpDriver()
	{
		$config = Config::get( 'mail' );

		// The Swift SMTP transport instance will allow us to use any SMTP backend
		// for delivering mail such as Sendgrid, Amazon SES, or a custom server
		// a developer has available. We will just pass this configured host.
		$transport = SmtpTransport::newInstance( $config['host'], $config['port'] );

		if ( isset( $config['encryption'] ) )
			$transport->setEncryption( $config['encryption'] );

		// Once we have the transport we will check for the presence of a username
		// and password. If we have it we will set the credentials on the Swift
		// transporter instance so that we'll properly authenticate delivery.
		if ( isset( $config['username'] ) )
		{
			$transport->setUsername( $config['username'] );
			$transport->setPassword( $config['password'] );
		}

		if ( isset( $config['stream'] ) )
			$transport->setStreamOptions( $config['stream'] );

		return $transport;
	}
603389
public static function transport(): Swift_Transport
    {
        switch (Site::getPreference('SMTP_ACTIVE')) {
            case 'sendmail':
                // Local sendmail (requires PHP proc_* functions)
                return new Swift_SendmailTransport();

            case 'external':
                // SMTP
                $smtp_host = Site::getPreference('SMTP_HOST');
                $smtp_port = (int) Site::getPreference('SMTP_PORT', '25');
                $smtp_auth = Site::getPreference('SMTP_AUTH');
                $smtp_user = Site::getPreference('SMTP_AUTH_USER');
                $smtp_pass = Site::getPreference('SMTP_AUTH_PASS');
                $smtp_encr = Site::getPreference('SMTP_SSL');

                $transport = new Swift_SmtpTransport($smtp_host, $smtp_port, $smtp_encr);

                $transport->setLocalDomain(Site::getPreference('SMTP_HELO'));

                if ($smtp_auth) {
                    $transport
                        ->setUsername($smtp_user)
                        ->setPassword($smtp_pass);
                }

                return $transport;

            default:
                // For testing
                return new Swift_NullTransport();
        }
    }
1289578
public function send()
    {

        if ($this->Logger->isEnabled()) {

            $this->Logger->debug($this->message->toString());

        }


        //Now check if Swift actually sends it
        if (!$this->testingOnly) {

            //Now check if Swift actually sends it
            $this->getMailer()->send($this->message);

        }
        return $this;

    }
856134
public function getTransport() {
        if($this->transport === null) {
            $this->transport = $this->getServiceManager()
                ->get('goaliomailservice_transport');
        }

        return $this->transport;
    }
1183745
protected function createSesDriver()
    {
        $config = array_merge($this->app['config']->get('services.ses', []), [
            'version' => 'latest', 'service' => 'email',
        ]);

        return new SesTransport(
            new SesClient($this->addSesCredentials($config)),
            $config['options'] ?? []
        );
    }
734469
protected function createSesDriver()
    {
        $config = [
            'version' => 'latest', 'service' => 'email',
            'key' => $this->getSecureConfig('key'),
            'secret' => $this->getSecureConfig('secret'),
            'region' => $this->getConfig('region'),
            'options' => [],
        ];

        return new SesTransport(
            new SesClient($this->addSesCredentials($config)), []
        );
    }
726853
public function send()
    {
        $transport = $this->getConnection()->getTransportObject();

        // Refactor: Not full toArray needed in exec?
        return $transport->exec($this, $this->getConnection()->toArray());
    }
1345108
private function getTransport()
    {
        switch ($this->transport)
        {
            case 'stream':
                return new Transport\Stream($this->host, $this->port);

            case 'curl':
            default:
                return new Transport\Curl($this->host, $this->port);
        }
    }
673631
public function mail() {
		// if the instance has not been created yet
		if (!isset($this->mail)) {
			// create the instance

			$transport = null;

			if (isset($_ENV['MAIL_TRANSPORT'])) {
				if ($_ENV['MAIL_TRANSPORT'] === 'smtp') {
					$transport = \Swift_SmtpTransport::newInstance();
					$transport->setHost($_ENV['MAIL_HOST']);
					$transport->setPort($_ENV['MAIL_PORT']);
					$transport->setUsername($_ENV['MAIL_USERNAME']);
					$transport->setPassword($_ENV['MAIL_PASSWORD']);

					if (!empty($_ENV['MAIL_TLS'])) {
						$transport->setEncryption('tls');
					}
				}
				elseif ($_ENV['MAIL_TRANSPORT'] === 'sendmail') {
					$sendmailPath = ini_get('sendmail_path');

					if (empty($sendmailPath)) {
						$sendmailPath = '/usr/sbin/sendmail';
					}

					$transport = \Swift_SendmailTransport::newInstance($sendmailPath);
				}
				elseif ($_ENV['MAIL_TRANSPORT'] === 'php') {
					$transport = \Swift_MailTransport::newInstance();
				}
			}

			if (isset($transport)) {
				$this->mail = \Swift_Mailer::newInstance($transport);
			}
		}

		// return the instance
		return $this->mail;
	}
843204
private function getSmtpTransport(): \Swift_SmtpTransport
    {
        $object = new \Swift_SmtpTransport(
            $this->config('smtp.host'),
            $this->config('smtp.port'),
            $this->config('smtp.encryption')
        );

        return $object
            ->setUsername($this->config('smtp.username'))
            ->setPassword($this->config('smtp.password'))
        ;
    }
790462
public function init() {
		$this->_swift['transport'] = \Swift_SmtpTransport::newInstance($this->smtp, $this->port, true === $this->ssl ? 'ssl' : '');
		$this->_swift['transport']->setUsername($this->username);
		$this->_swift['transport']->setPassword($this->password);
		
		$this->_swift['mailer'] = \Swift_mailer::newInstance($this->_swift['transport']);
		
		$this->_swift['message'] = \Swift_message::newInstance();
		
		return $this;
	}
668391
protected function createSendgridDriver()
    {
        $config = $this->app['config']->get('services.sendgrid', array());
        $client = new HttpClient(Arr::get($config, 'guzzle', []));
        return new SendgridTransport($client, $config['api_key']);
    }
42888
public function getTransport()
    {
        if (!self::$mailer) {

            self::$mailer = $this->getMailSystem()->getTransport();
            Events::dispatch('onMailTransport', array('transport' => self::$mailer));
        }
        return self::$mailer;
    }
3170
function getClient()
    {
        $transport = $this->getTransport();
        $transport->setAuth($this->username, $this->password);

        return new Client($transport);
    }
1363844
protected function createTransport(array $config)
    {
        if (!isset($config['class'])) {
            $config['class'] = 'Swift_SendmailTransport';
        }
        if (isset($config['plugins'])) {
            $plugins = $config['plugins'];
            unset($config['plugins']);
        } else {
            $plugins = [];
        }

        if ($this->enableSwiftMailerLogging) {
            $plugins[] = [
                'class' => 'Swift_Plugins_LoggerPlugin',
                'constructArgs' => [
                    [
                        'class' => 'yii\swiftmailer\Logger'
                    ]
                ],
            ];
        }

        /* @var $transport \Swift_Transport */
        $transport = $this->createSwiftObject($config);
        if (!empty($plugins)) {
            foreach ($plugins as $plugin) {
                if (is_array($plugin) && isset($plugin['class'])) {
                    $plugin = $this->createSwiftObject($plugin);
                }
                $transport->registerPlugin($plugin);
            }
        }

        return $transport;
    }