コード例 #1
0
 public function testImage()
 {
     $mail = $this->_root;
     $c = $mail->getComponent();
     $html = $c->getHtml();
     $mail = new Kwf_Mail();
     $mail->setBodyHtml($html, null, Zend_Mime::ENCODING_8BIT);
     $url = 'http://' . Kwf_Config::getValue('server.domain') . '/assets/kwf/images/rating/ratingStarFull.jpg';
     $this->assertEquals('<img src="' . $url . '" width="13" height="12" alt="" />', $mail->getBodyHtml(true));
     $mail = new Kwf_Mail();
     $mail->setAttachImages(true);
     $mail->setBodyHtml($html, null, Zend_Mime::ENCODING_8BIT);
     $this->assertEquals('<img src="cid:d8c33cb4a497ce1919c3662b7c5df05f" width="13" height="12" alt="" />', $mail->getBodyHtml(true));
 }
コード例 #2
0
 public function send($transport = null)
 {
     if (!$transport) {
         $transport = new Kwc_FormDynamic_Basic_Form_Form_TestTransport();
     }
     return parent::send($transport);
 }
コード例 #3
0
 public function indexAction()
 {
     $this->_start();
     if (Kwf_Config::getValue('debug.mailProcessControlOutput')) {
         $logFiles = array();
         foreach ($this->_commands as $requiredCmd) {
             $logFiles[] = "log/{$requiredCmd['cmd']}.log";
             $logFiles[] = "log/{$requiredCmd['cmd']}.err";
         }
         $msg = '';
         foreach ($logFiles as $logFile) {
             if (!file_exists($logFile)) {
                 continue;
             }
             if (!filesize($logFile)) {
                 continue;
             }
             if ($this->_getParam('debug')) {
                 echo "{$logFile}: " . filesize($logFile) . " bytes\n";
             }
             $tempFile = tempnam('temp/', 'log');
             copy($logFile, $tempFile);
             $fp = fopen($logFile, 'w');
             ftruncate($fp, filesize($tempFile) - filesize($logFile));
             fclose($fp);
             $msg .= date('Y-m-d H:i:s') . " {$logFile}:\n";
             $msg .= trim(file_get_contents($tempFile)) . "\n";
         }
         if ($msg) {
             $mail = new Kwf_Mail();
             $mail->setSubject(Kwf_Config::getValue('server.domain') . ' process-control output');
             $mail->setBodyText($msg);
             foreach (Kwf_Registry::get('config')->developers as $d) {
                 if ($d->sendProcessControlOutput) {
                     $d->email;
                     $mail->addTo($d->email);
                 }
             }
             $mail->send();
         }
     }
     exit;
 }
コード例 #4
0
 public static function getSettings()
 {
     $ret = parent::getSettings();
     $ret['generators']['content'] = array('class' => 'Kwf_Component_Generator_Static', 'component' => 'Kwc_Paragraphs_Component');
     $sender = Kwf_Mail::getSenderFromConfig();
     $ret['default'] = array('from_email' => $sender['address'], 'from_name' => $sender['name']);
     $ret['editFrom'] = true;
     $ret['editReplyTo'] = true;
     $ret['assetsAdmin']['files'][] = 'kwf/Kwc/Mail/PreviewWindow.js';
     $ret['assetsAdmin']['dep'][] = 'ExtWindow';
     $ret['ownModel'] = 'Kwc_Mail_Model';
     $ret['componentName'] = 'Mail';
     return $ret;
 }
コード例 #5
0
 protected function _beforeSave(Kwf_Model_Row_Interface $row)
 {
     parent::_beforeSave($row);
     $mail = new Kwf_Mail();
     $user = Kwf_Registry::get('userModel')->getAuthedUser();
     $mail->setReturnPath('noreply@' . preg_replace('#^www\\.#', '', Kwf_Config::getValue('server.domain')));
     $mail->setFrom($user->email, $user->__toString());
     foreach (Kwf_Registry::get('config')->developers as $dev) {
         if (isset($dev->sendClearCacheReport) && $dev->sendClearCacheReport) {
             $mail->addTo($dev->email);
         }
     }
     $mail->setSubject('Clear Cache Report. Affected: ' . $row->clear_cache_affected);
     $mail->setBodyText("Clear Cache Report\n\n" . "Web: " . Kwf_Registry::get('config')->application->name . " (" . Kwf_Registry::get('config')->application->id . ")\n" . "User: "******"\n" . "Time: " . date("d.m.Y, H:i:s") . "\n\n" . "Affected component / part:\n" . $row->clear_cache_affected . "\n\n" . "Steps to reproduce / description:\n" . $row->clear_cache_comment . "\n");
     $mail->send();
     $row->clear_cache_affected = '';
     $row->clear_cache_comment = '';
 }
コード例 #6
0
 protected function _afterInsert(Kwf_Model_Row_Interface $row)
 {
     parent::_afterInsert($row);
     if (isset($_SERVER['HTTP_HOST'])) {
         $host = $_SERVER['HTTP_HOST'];
     } else {
         $host = Kwf_Registry::get('config')->server->domain;
     }
     if (substr($host, 0, 4) == 'www.') {
         $host = substr($host, 4);
     }
     $fromMailAddress = $this->_getSetting('fromMailAdress');
     if ($fromMailAddress) {
         $row->setFrom($fromMailAddress);
     } else {
         $row->setFrom("noreply@{$host}");
     }
     $settings = $this->getData()->parent->getComponent()->getMailSettings();
     $row->addTo($settings['recipient']);
     if ($settings['recipient_cc']) {
         $row->addCc($settings['recipient_cc']);
     }
     $row->setSubject(str_replace('%number%', $row->id, $settings['subject']));
     $row->setCheckSpam($settings['check_spam']);
     $msg = '';
     $formFieldComponents = self::_findFormFields($this->getData()->parent->getChildComponent('-paragraphs'));
     foreach ($formFieldComponents as $c) {
         $message = $c->getComponent()->getSubmitMessage($row);
         if ($message) {
             $msg .= $message . "\n";
         }
     }
     $row->sent_mail_content_text = $msg;
     $this->_beforeSendMail($row);
     $row->sendMail();
     //manuell aufrufen weils beim speichern nicht automatisch gemacht wird (da da der content nocht nicht vorhanden ist)
     if ($settings['send_confirm_mail']) {
         $c = Kwf_Component_Data_Root::getInstance()->getComponentById($settings['confirm_field_component_id']);
         if ($c && ($recipient = $row->{$c->getComponent()->getFormField()->getName()})) {
             $mail = new Kwf_Mail();
             $body = $this->getData()->trlKwf('Thank you for your inquiry, it will be processed as soon as posible.');
             $body .= "\n\n";
             $body .= $msg;
             $mail->setSubject(str_replace('%number%', $row->id, $settings['confirm_subject']));
             $mail->setBodyText($body);
             $mail->addTo($recipient);
             $mail->send();
         }
     }
 }
コード例 #7
0
 public function createMail(Kwc_Mail_Recipient_Interface $recipient, $data = null, $toAddress = null, $format = null, $addViewTracker = true)
 {
     $this->_mailData = $data;
     $mail = new Kwf_Mail();
     $name = $recipient->getMailFirstname() . ' ' . $recipient->getMailLastname();
     if (!$recipient->getMailFirstname() || !$recipient->getMailLastname()) {
         //no name at all if we don't have a complete name
         $name = null;
     }
     if ($toAddress) {
         $mail->addTo($toAddress, $name);
     } else {
         $mail->addTo($recipient->getMailEmail(), $name);
     }
     if (!$format && $recipient->getMailFormat() == Kwc_Mail_Recipient_Interface::MAIL_FORMAT_HTML || $format == Kwc_Mail_Recipient_Interface::MAIL_FORMAT_HTML) {
         $html = $this->getHtml($recipient, $addViewTracker);
         $mail->setDomain($this->getData()->getDomain());
         $mail->setAttachImages($this->_getSetting('attachImages'));
         $mail->setBodyHtml($html);
     }
     $mail->setBodyText($this->getText($recipient));
     $mail->setSubject($this->getSubject($recipient));
     if ($this->_getSetting('fromEmail')) {
         $mail->setFrom($this->_getSetting('fromEmail'), $this->_getSetting('fromName'));
     }
     if ($this->_getSetting('replyEmail')) {
         $mail->setReplyTo($this->_getSetting('replyEmail'));
     }
     if ($this->_getSetting('returnPath')) {
         $mail->setReturnPath($this->_getSetting('returnPath'));
     }
     $bccs = $this->_getSetting('bcc');
     if ($bccs) {
         if (!is_array($bccs)) {
             $bccs = array($bccs);
         }
         foreach ($bccs as $bcc) {
             $mail->addBcc($bcc);
         }
     }
     return $mail;
 }