public function create(): PHPMailer
    {
        // can initial, can't use
        if (!class_exists(PHPMailer::class)) {
            throw new ComponentException(
                "PHPMailer library is required for `Bluz\\Mailer` package. <br/>\n" .
                "Read more: <a href='https://github.com/bluzphp/framework/wiki/Mailer'>" .
                "https://github.com/bluzphp/framework/wiki/Mailer</a>"
            );
        }

        $mail = new PHPMailer();
        $mail->WordWrap = 920; // RFC 2822 Compliant for Max 998 characters per line

        $fromEmail = $this->getOption('from', 'email');
        $fromName = $this->getOption('from', 'name') ?: '';

        // setup options from config
        $mail->setFrom($fromEmail, $fromName, false);

        // setup options
        if ($settings = $this->getOption('settings')) {
            foreach ($settings as $name => $value) {
                $mail->set($name, $value);
            }
        }

        // setup custom headers
        if ($headers = $this->getOption('headers')) {
            foreach ($headers as $header => $value) {
                $mail->addCustomHeader($header, $value);
            }
        }

        return $mail;
    }
public function create(): PHPMailer
    {
        // can initial, can't use
        if (!class_exists(PHPMailer::class)) {
            throw new ComponentException(
                "PHPMailer library is required for `Bluz\\Mailer` package. <br/>\n" .
                "Read more: <a href='https://github.com/bluzphp/framework/wiki/Mailer'>" .
                "https://github.com/bluzphp/framework/wiki/Mailer</a>"
            );
        }

        $mail = new PHPMailer();
        $mail->WordWrap = 920; // RFC 2822 Compliant for Max 998 characters per line

        $fromEmail = $this->getOption('from', 'email');
        $fromName = $this->getOption('from', 'name') ?: '';

        // setup options from config
        $mail->setFrom($fromEmail, $fromName, false);

        // setup options
        if ($settings = $this->getOption('settings')) {
            foreach ($settings as $name => $value) {
                $mail->set($name, $value);
            }
        }

        // setup custom headers
        if ($headers = $this->getOption('headers')) {
            foreach ($headers as $header => $value) {
                $mail->addCustomHeader($header, $value);
            }
        }

        return $mail;
    }
public function create ( ) : PHPMailer { // can initial, can't use if ( ! class_exists ( PHPMailer :: class ) ) { throw new ComponentException ( "PHPMailer library is required for `Bluz\\Mailer` package. <br/>\n" . "Read more: <a href='https://github.com/bluzphp/framework/wiki/Mailer'>" . "https://github.com/bluzphp/framework/wiki/Mailer</a>" ) ; } $ mail = new PHPMailer ( ) ; $ mail -> WordWrap = 920 ; // RFC 2822 Compliant for Max 998 characters per line $ fromEmail = $ this -> getOption ( 'from' , 'email' ) ; $ fromName = $ this -> getOption ( 'from' , 'name' ) ? : '' ; // setup options from config $ mail -> setFrom ( $ fromEmail , $ fromName , false ) ; // setup options if ( $ settings = $ this -> getOption ( 'settings' ) ) { foreach ( $ settings as $ name => $ value ) { $ mail -> set ( $ name , $ value ) ; } } // setup custom headers if ( $ headers = $ this -> getOption ( 'headers' ) ) { foreach ( $ headers as $ header => $ value ) { $ mail -> addCustomHeader ( $ header , $ value ) ; } } return $ mail ; }
Creates new instance of PHPMailer and set default options from config

@return PHPMailer
@throws ComponentException
@throws \PHPMailer\PHPMailer\Exception
Creates new instance of PHPMailer and set default options from config