/**
  * Creates a SmtpTransport.
  *
  * @return SmtpTransport the instance created
  */
 public function create()
 {
     $host = ArrayHelper::remove($this->options, 'host');
     $port = ArrayHelper::remove($this->options, 'port');
     $options = ArrayHelper::getValue($this->options, 'options', []);
     return new SmtpTransport($host, $port, $options);
 }
 /**
  * @param $key
  * @param null $default
  *
  * @return mixed
  */
 protected function getConfigurationValue($key, $default = null)
 {
     return ArrayHelper::getValue($this->configuration, $key, $default);
 }
Exemplo n.º 3
0
 /**
  * Sends a MailMessage instance.
  *
  * View files can be added to the `$views` array argument and if set, they will be parsed via the `PhpViewFileHelper`
  * helper that this library contains.
  *
  * The `$view` argument has the following syntax:
  *
  * ```
  * $view = [
  *   'text' => '/path/to/plain/text/email.php',
  *   'html' => '/path/to/html/email.php'
  * ];
  * ```
  * The `PhpViewFileHelper` will use the `$data` array argument to parse the templates.
  *
  * The template files must be of `php` type if you wish to use internal system. Otherwise, is highly recommended to
  * use your own template parser and set the `bodyHtml` and `bodyText` of the `MailMessage` class.
  *
  * @param MailMessage $message the MailMessage instance to send
  * @param array $views the view files for `text` and `html` templates
  * @param array $data the data to be used for parsing the templates
  *
  * @return array|null
  *
  * @see PhpViewFileHelper::render()
  * @see MailMessage::$bodyHtml
  * @see MailMessage::$bodyText
  */
 public function send(MailMessage $message, array $views = [], array $data = [])
 {
     foreach (['text', 'html'] as $view) {
         $viewFile = ArrayHelper::getValue($views, $view);
         if ($viewFile !== null) {
             $content = PhpViewFileHelper::render($viewFile, $data);
             $attribute = 'body' . ucfirst($view);
             $message->{$attribute} = $content;
         }
     }
     return $this->sendSwiftMessage($message->asSwiftMessage());
 }
 /**
  * Creates and instance from an array
  *
  * @param $config
  *
  * @return SmtpCredentialsValidator
  */
 public static function fromArray($config)
 {
     return new SmtpCredentialsValidator(ArrayHelper::getValue($config, 'host'), ArrayHelper::getValue($config, 'port'), ArrayHelper::getValue($config, 'username'), ArrayHelper::getValue($config, 'password'), ArrayHelper::getValue($config, 'encryption'), ArrayHelper::getValue($config, 'authMode'));
 }