コード例 #1
0
ファイル: Email.php プロジェクト: ipitbiz/bolt
 /**
  * Compose the email data to be sent.
  *
  * @param FormConfig  $formConfig
  * @param EmailConfig $emailConfig
  * @param FormData    $formData
  */
 private function emailCompose(FormConfig $formConfig, EmailConfig $emailConfig, FormData $formData)
 {
     /*
      * Create message object
      */
     $this->message = \Swift_Message::newInstance();
     $this->message->setEncoder(\Swift_Encoding::get8BitEncoding());
     // Set our Twig lookup path
     $this->addTwigPath();
     // If the form has it's own templates defined, use those, else the globals.
     $templateSubject = $formConfig->getTemplates()->getSubject() ?: $this->config['templates']['subject'];
     $templateEmail = $formConfig->getTemplates()->getEmail() ?: $this->config['templates']['email'];
     $fieldmap = $this->config['fieldmap']['email'];
     /*
      * Subject
      */
     $html = $this->app['render']->render($templateSubject, array($fieldmap['subject'] => $formConfig->getNotification()->getSubject(), $fieldmap['config'] => $emailConfig, $fieldmap['data'] => $formData));
     $subject = new \Twig_Markup($html, 'UTF-8');
     /*
      * Body
      */
     $html = $this->app['render']->render($templateEmail, array($fieldmap['fields'] => $formConfig->getFields(), $fieldmap['config'] => $emailConfig, $fieldmap['data'] => $this->getBodyData($emailConfig, $formData)));
     $body = new \Twig_Markup($html, 'UTF-8');
     $text = preg_replace('/<style\\b[^>]*>(.*?)<\\/style>/s', '', $body);
     /*
      * Build email
      */
     $this->message->setSubject($subject)->setBody(strip_tags($text))->addPart($body, 'text/html');
 }
コード例 #2
0
 /**
  * Get resolved email configuration settings.
  */
 private function setEmailConfig()
 {
     $notify = $this->formConfig->getNotification();
     $hashMap = array('fromName' => 'from_name', 'fromEmail' => 'from_email', 'replyToName' => 'replyto_name', 'replyToEmail' => 'replyto_email', 'toName' => 'to_name', 'toEmail' => 'to_email', 'ccName' => 'cc_name', 'ccEmail' => 'cc_email', 'bccName' => 'bcc_name', 'bccEmail' => 'bcc_email');
     foreach ($hashMap as $property => $key) {
         $this->{$property} = $this->getConfigValue($notify->{$key});
     }
 }
コード例 #3
0
ファイル: Processor.php プロジェクト: pkdevboxy/boltforms
 /**
  * Send email notifications if configured.
  *
  * @param FormConfig $formConfig
  * @param FormData   $formData
  */
 protected function processEmailNotification(FormConfig $formConfig, FormData $formData)
 {
     if ($formConfig->getNotification()->getEnabled()) {
         $this->app['boltforms.email']->doNotification($formConfig, $formData);
     }
 }