{@inheritdoc}

@param \Ems\Contracts\Mail\MailConfig $config
@param \DateTime                      $plannedSendDate (optional)

@return \Ems\Contracts\Mail\MailContent
511492
public function contentsFor(MailConfig $config, DateTime $plannedSendDate = null)
    {
        return $this->model->where($this->configForeignKey, $config->getId())->first();
    }
1090860
protected function fill(Mailable $mailable): Mailable
    {
        return $mailable->to($this->to)
                        ->cc($this->cc)
                        ->bcc($this->bcc)
                        ->locale($this->locale);
    }
309378
public function updatePlan($planCode, $updateData)
    {
        return $this->getPlanModel()->getPlan($planCode)
            ->setUpdateData($updateData)
            ->save();
    }
904831
public function sendMulti($reciversMessage, $date = '', $senderID = '')
    {
        //Pre-checks act1
        if ($senderID == null || !strlen(trim($senderID))) {
            $senderID = $this->config['default_sender'];
        }

        //Sending for future date
        $dateStr = '';
        if (strlen($date)) {
            $dateStr = ' tarih="' . $date . '"';
        }

        $xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<smspack ka="' . $this->config['auth']['username'] . '" pwd="' . $this->config['auth']['password'] . '"' . $dateStr . ' org="' . $senderID . '" charset="' . $this->config['charset'] . '"' . ($this->config['append_unsubscribe_link'] ? ' addLinkToEnd="true"' : '') . '>';

        foreach ($reciversMessage as $eachMessageBlock) {
            $number = $eachMessageBlock[0];
            $message = $eachMessageBlock[1];

            $xml .= '<mesaj>' . '<metin>' . $message . '</metin>' . '<nums>' . $number . '</nums>' . '</mesaj>';
        }

        $xml .= '</smspack>';

        return $this->postXML($xml, 'https://smsgw.mutlucell.com/smsgw-ws/sndblkex');
    }
294508
protected function _applyConfig($config)
    {
        if (is_string($config)) {
            $name = $config;
            $config = static::getConfig($name);
            if (empty($config)) {
                throw new InvalidArgumentException(sprintf('Unknown email configuration "%s".', $name));
            }
            unset($name);
        }

        $this->_profile = array_merge($this->_profile, $config);

        $simpleMethods = [
            'from', 'sender', 'to', 'replyTo', 'readReceipt', 'returnPath',
            'cc', 'bcc', 'messageId', 'domain', 'subject', 'attachments',
            'transport', 'emailFormat', 'emailPattern', 'charset', 'headerCharset'
        ];
        foreach ($simpleMethods as $method) {
            if (isset($config[$method])) {
                $this->{'set' . ucfirst($method)}($config[$method]);
            }
        }

        if (empty($this->headerCharset)) {
            $this->headerCharset = $this->charset;
        }
        if (isset($config['headers'])) {
            $this->setHeaders($config['headers']);
        }

        $viewBuilderMethods = [
            'template', 'layout', 'theme'
        ];
        foreach ($viewBuilderMethods as $method) {
            if (array_key_exists($method, $config)) {
                $this->viewBuilder()->{'set' . ucfirst($method)}($config[$method]);
            }
        }

        if (array_key_exists('helpers', $config)) {
            $this->viewBuilder()->setHelpers($config['helpers'], false);
        }
        if (array_key_exists('viewRender', $config)) {
            $this->viewBuilder()->setClassName($config['viewRender']);
        }
        if (array_key_exists('viewVars', $config)) {
            $this->set($config['viewVars']);
        }
    }
288482
private function sendEmail($to = '', $subject = '', $messageText = '')
    {
        $transport = $this->getServiceLocator()->get('mail.transport');
        $message = new Message();
            
        $message->addTo($to)
                ->addFrom($this->getOptions()->getSenderEmailAdress())
                ->setSubject($subject)
                ->setBody($messageText);

        $transport->send($message);
    }
977547
protected function composeMessage($notification)
    {
        if(empty($this->message['to'])){
            throw new InvalidConfigException('The "to" option must be set in EmailChannel::message.');
        }
        $message = $this->mailer->compose();
        Yii::configure($message, $this->message);
        $message->setSubject((string)$notification->getTitle());
        $message->setTextBody((string)$notification->getDescription());
        return $message;
    }
721865
protected static function mergeCommandOptionsIntoConfiguration(Configuration $config, InputExtendedInterface $input)
    {
        $configurationMapping = [
            // Database credentials
            'database-host' => 'Database.Host',
            'database-user' => 'Database.Username',
            'database-pass' => 'Database.Password',
            'database-port' => 'Database.Port',
            'database-name' => 'Database.Name',
            // SSH settings
            'ssh-key'       => 'SSH.KeyFile',
        ];

        foreach ($configurationMapping as $optionName => $configName) {
            if ($input->isOptionSet($optionName) === true) {
                $config->setConfigurationValue($configName, $input->getOption($optionName));

            // If the value is not set / available, set this to nothing
            } elseif (!$config->getConfigurationValue($configName)) {
                $config->setConfigurationValue($configName, null);
            }
        }

        return $config;
    }
685
public static function fromString(Text $configString)
    {
        $scope = new Scope();
        while (false === $configString->eof()) {

            if (true === $configString->isEmptyLine()) {
                $scope->addPrintable(EmptyLine::fromString($configString));
            }

            $char = $configString->getChar();

            if ('#' === $char) {
                $scope->addPrintable(Comment::fromString($configString));
                continue;
            }

            if (('a' <= $char) && ('z' >= $char)) {
                $scope->addDirective(Directive::fromString($configString));
                continue;
            }

            if ('}' === $configString->getChar()) {
                break;
            }

            $configString->inc();
        }
        return $scope;
    }
1035396
public function send($subject, $content, $to, $fromName = '', $fromEmail = '')
    {
        $mail      = new CakeEmail();
        $fromName  = ($fromName !== '') ? $fromName : $this->_fromName;
        $fromEmail = ($fromEmail !== '') ? $fromEmail : $this->_fromEmail;
        $transport = new MailTransport();

        return $mail
            ->setTransport($transport)
            ->setTemplate($this->_tpl)
            ->setEmailFormat($this->_format)
            ->setFrom($fromEmail, $fromName)
            ->setTo($to)
            ->setSubject($subject)
            ->setViewVars(['page_title' => $subject])
            ->send($content);
    }
696472
protected function assureContentsInData(MailConfig $config, array &$data, DateTime $plannedSendDate = null)
    {
        if ($this->contentProvider) {
            $this->assureContentsByProvider($config, $data, $plannedSendDate);
            return;
        }

        if (!isset($data[self::SUBJECT])) {
            throw new UnderflowException('You have to pass subject (and body) inside $data');
        }

    }
526258
public function setProfile($config) {
		if (!is_array($config)) {
			$config = (string)$config;
		}
		$this->_applyConfig($config);

		$fromEmail = Configure::read('Config.systemEmail');
		if ($fromEmail) {
			$fromName = Configure::read('Config.systemName');
		} else {
			$fromEmail = Configure::read('Config.adminEmail');
			$fromName = Configure::read('Config.adminName');
		}
		if ($fromEmail) {
			$this->setFrom($fromEmail, $fromName);
		}

		$xMailer = Configure::read('Config.xMailer');
		if ($xMailer) {
			$this->addHeaders(['X-Mailer' => $xMailer]);
		}

		return $this;
	}
1344067
protected function configureMail(array $config = [])
    {
        $config = array_merge([
            'MAIL_DRIVER'     => null,
            'MAIL_HOST'       => null,
            'MAIL_PORT'       => null,
            'MAIL_USERNAME'   => null,
            'MAIL_PASSWORD'   => null,
            'MAIL_ADDRESS'    => null,
            'MAIL_NAME'       => null,
            'MAIL_ENCRYPTION' => null,
        ], $config);

        // Don't continue with these settings if we're not interested in notifications.
        if (!$this->confirm('Do you want Cachet to send mail notifications?')) {
            return;
        }

        $config['MAIL_DRIVER'] = $this->choice('What driver do you want to use to send notifications?', [
            'smtp'      => 'SMTP',
            'mail'      => 'Mail',
            'sendmail'  => 'Sendmail',
            'mailgun'   => 'Mailgun',
            'mandrill'  => 'Mandrill',
            'ses'       => 'Amazon SES',
            'sparkpost' => 'SparkPost',
            'log'       => 'Log (Testing)',
        ]);

        if (!$config['MAIL_DRIVER'] === 'log') {
            if ($config['MAIL_DRIVER'] === 'smtp') {
                $config['MAIL_HOST'] = $this->ask('Please supply your mail server host');
            }

            $config['MAIL_ADDRESS'] = $this->ask('What email address should we send notifications from?');
            $config['MAIL_USERNAME'] = $this->ask('What username should we connect as?');
            $config['MAIL_PASSWORD'] = $this->secret('What password should we connect with?');
        }

        // Format the settings ready to display them in the table.
        $this->formatConfigsTable($config);

        if (!$this->confirm('Are these settings correct?')) {
            return $this->configureMail($config);
        }

        foreach ($config as $setting => $value) {
            $this->writeEnv($setting, $value);
        }
    }
194599
public function text($content, $param = [], $config = [])
    {
        if ($param) {
            $content = strtr($content, $this->parseParam($param, $config));
        }
        $this->message->setBody($content, MailerConfig::CONTENT_PLAIN);

        return $this;
    }
369673
public static function createPdoConnectionByConfig($config)
    {
        $timezone = config('pckg.locale.timezone', 'Europe/Ljubljana');
        $charset = $config['charset'] ?? 'utf8';
        $partDb = isset($config['db'])
            ? ";dbname=" . $config['db']
            : '';
        $options = [
            PDO::MYSQL_ATTR_INIT_COMMAND => 'SET time_zone = \'' . $timezone . '\';',
            PDO::ATTR_STRINGIFY_FETCHES => false,
            PDO::ATTR_EMULATE_PREPARES => false,
        ];

        return new PDO(
            "mysql:host=" . $config['host'] . ";charset=" . $charset . $partDb,
            $config['user'],
            $config['pass'],
            $options
        );
    }
587983
protected static function mergeCommandArgumentsIntoConfiguration(Configuration $config, InputExtendedInterface $input)
    {
        if ($input->hasArgument('instances') === false) {
            return $config;
        }

        $argumentInstances = $input->getArgument('instances');

        if (count($argumentInstances) === 0) {
            return $config;
        }

        // Gerrie is a reserved keyword for project names
        $config->setConfigurationValue('Gerrit.Gerrie', $argumentInstances);

        return $config;
    }
473801
public function setConfiguration( models\VPN\Server\Config\ServerConfig $serverConfig){
        $service = sprintf( self::API_VPN_SERVER_CONFIG, $serverConfig->getId());
        $rest = $this->getService( $service);
        $rest->PUT( $serverConfig);

        return $rest->getResult( models\VPN\Server\Config\ServerConfig::class);
    }