app/Mail.php
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();
        }
    }
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();
        }
    }
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 ( ) ; } }
Create a transport mechanism for sending mail

@return Swift_Transport
Create a transport mechanism for sending mail