AcmePhp\Cli\Monitoring\EmailHandlerBuilder::createHandler PHP Method

createHandler() public method

public createHandler ( $config )
    public function createHandler($config)
    {
        if (!isset($config['host'])) {
            throw new AcmeCliException('The SMTP host (key "host") is required in the email monitoring alert handler.');
        }
        if (!isset($config['to'])) {
            throw new AcmeCliException('The mail recipient (key "to") is required in the email monitoring alert handler.');
        }
        $config = array_merge(self::$defaults, $config);
        $transport = new \Swift_SmtpTransport($config['host'], $config['port'], $config['encryption']);
        if ($config['username']) {
            $transport->setUsername($config['username']);
        }
        if ($config['password']) {
            $transport->setPassword($config['password']);
        }
        $message = new \Swift_Message($config['subject']);
        $message->setFrom($config['from']);
        $handler = new SwiftMailerHandler(new \Swift_Mailer($transport), $message);
        return new FingersCrossedHandler($handler, $config['level']);
    }
EmailHandlerBuilder