当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Mail::createAttachment方法代码示例

本文整理汇总了PHP中Zend_Mail::createAttachment方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Mail::createAttachment方法的具体用法?PHP Zend_Mail::createAttachment怎么用?PHP Zend_Mail::createAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Mail的用法示例。


在下文中一共展示了Zend_Mail::createAttachment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendExceptionByMail

 public static function sendExceptionByMail(Exception $e, $from, $to)
 {
     // generate mail datas
     $subject = '[' . MAIN_URL . ':' . CONFIG_ENV . '] Exception Report: ' . wordlimit_bychar($e->getMessage(), 50);
     $body = $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine();
     // sned mail throw Zend_Mail
     $mail = new Zend_Mail();
     $mail->setSubject($subject)->setFrom($from)->setBodyText($body);
     $emails = explode(' ', $to);
     foreach ($emails as $email) {
         $mail->addTo($email);
     }
     $att = $mail->createAttachment(var_export($_GET, true), Zend_Mime::TYPE_TEXT);
     $att->filename = 'GET.txt';
     $att = $mail->createAttachment(var_export($_POST, true), Zend_Mime::TYPE_TEXT);
     $att->filename = 'POST.txt';
     // send session dump only if exists
     if (session_id() != null) {
         $att = $mail->createAttachment(var_export($_SESSION, true), Zend_Mime::TYPE_TEXT);
         $att->filename = 'SESSION.txt';
     }
     $att = $mail->createAttachment(var_export($_SERVER, true), Zend_Mime::TYPE_TEXT);
     $att->filename = 'SERVER.txt';
     $att = $mail->createAttachment($e->getTraceAsString(), Zend_Mime::TYPE_TEXT);
     $att->filename = 'backtraceExeption.txt';
     $mail->send();
 }
开发者ID:hartum,项目名称:basezf,代码行数:27,代码来源:Handler.php

示例2: saveFiles

 public function saveFiles($fileArray)
 {
     if (empty($fileArray)) {
         return array();
     }
     // Init connection
     $this->initConnection();
     $savedFiles = array();
     @ini_set('SMTP', Mage::getStoreConfig('system/smtp/host'));
     @ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port'));
     $charset = "utf-8";
     #$charset = "iso-8859-1";
     $mail = new Zend_Mail($charset);
     $setReturnPath = Mage::getStoreConfig('system/smtp/set_return_path');
     switch ($setReturnPath) {
         case 1:
             $returnPathEmail = $this->getDestination()->getEmailSender();
             break;
         case 2:
             $returnPathEmail = Mage::getStoreConfig('system/smtp/return_path_email');
             break;
         default:
             $returnPathEmail = null;
             break;
     }
     if ($returnPathEmail !== null) {
         $mailTransport = new Zend_Mail_Transport_Sendmail("-f" . $returnPathEmail);
         Zend_Mail::setDefaultTransport($mailTransport);
     }
     $mail->setFrom($this->getDestination()->getEmailSender(), $this->getDestination()->getEmailSender());
     foreach (explode(",", $this->getDestination()->getEmailRecipient()) as $email) {
         if ($charset === "utf-8") {
             $mail->addTo($email, '=?utf-8?B?' . base64_encode($email) . '?=');
         } else {
             $mail->addTo($email, $email);
         }
     }
     foreach ($fileArray as $filename => $data) {
         if ($this->getDestination()->getEmailAttachFiles()) {
             $attachment = $mail->createAttachment($data);
             $attachment->filename = $filename;
         }
         $savedFiles[] = $filename;
     }
     #$mail->setSubject($this->_replaceVariables($this->getDestination()->getEmailSubject(), $firstFileContent));
     if ($charset === "utf-8") {
         $mail->setSubject('=?utf-8?B?' . base64_encode($this->_replaceVariables($this->getDestination()->getEmailSubject(), implode("\n\n", $fileArray))) . '?=');
     } else {
         $mail->setSubject($this->_replaceVariables($this->getDestination()->getEmailSubject(), implode("\n\n", $fileArray)));
     }
     $mail->setBodyText(strip_tags($this->_replaceVariables($this->getDestination()->getEmailBody(), implode("\n\n", $fileArray))));
     $mail->setBodyHtml($this->_replaceVariables($this->getDestination()->getEmailBody(), implode("\n\n", $fileArray)));
     try {
         $mail->send(Mage::helper('xtcore/utils')->getEmailTransport());
     } catch (Exception $e) {
         $this->getTestResult()->setSuccess(false)->setMessage(Mage::helper('xtento_orderexport')->__('Error while sending email: %s', $e->getMessage()));
         return false;
     }
     return $savedFiles;
 }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:60,代码来源:Email.php

示例3: sendAction

 public function sendAction()
 {
     // 返回值数组
     $result = array();
     // 请求参数
     // $request = $this->getRequest()->getParams();
     $now = date('Y-m-d H:i:s');
     /* $data = array(
                'subject'       => $request['subject'],
                'to'            => $request['to'],
                'to_name'       => $request['to_name'],
                'cc'            => $request['cc'],
                'cc_name'       => $request['cc_name'],
                'content'       => $request['content'],
                'attachment'    => $request['attachment']
        ); */
     $data = array('subject' => 'test', 'to' => '14706931@qq.com', 'to_name' => '新大陆', 'cc' => 'leonli188@126.com', 'cc_name' => 'leon', 'content' => 'test123测试', 'charset' => 'utf-8', 'attachment' => null);
     echo '<pre>';
     print_r($data);
     $mailConfig = new Zend_Config_Ini(CONFIGS_PATH . '/application.ini', 'mail');
     $from = $mailConfig->smtp->from;
     $fromname = $mailConfig->smtp->fromname;
     $transport = new Zend_Mail_Transport_Smtp($mailConfig->smtp->server, $mailConfig->smtp->params->toArray());
     $mail = new Zend_Mail();
     $mail->setSubject($data['subject']);
     $mail->setBodyText($data['content'], $data['charset']);
     $mail->setFrom($from, $fromname);
     $mail->addTo($data['to'], $data['to_name']);
     $mail->addCc($data['cc'], $data['cc_name']);
     $mail->addAttachment('MailController.php');
     $mail->createAttachment(file_get_contents('E:\\sina.png'), 'image/png', Zend_Mime::DISPOSITION_INLINE, Zend_Mime::ENCODING_BASE64, 'sina.png');
     print_r($mail->send($transport));
     //echo Zend_Json::encode($result);
     exit;
 }
开发者ID:xindalu,项目名称:evolve,代码行数:35,代码来源:MailController.php

示例4: executeFeedback

 /**
  * Executes feedback action
  *
  */
 public function executeFeedback(sfRequest $request)
 {
     $section = $request->getParameter('section', false);
     $this->form = new aFeedbackForm($section);
     $this->feedbackSubmittedBy = false;
     $this->failed = false;
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Tag', 'Url'));
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter('feedback'), $request->getFiles('feedback'));
         // $this->form->bind(array_merge($request->getParameter('feedback'), array('captcha' => $request->getParameter('captcha'))), $request->getFiles('feedback'));
         if ($this->form->isValid()) {
             $feedback = $this->form->getValues();
             $feedback['browser'] = $_SERVER['HTTP_USER_AGENT'];
             try {
                 aZendSearch::registerZend();
                 $mail = new Zend_Mail();
                 $mail->setBodyText($this->getPartial('feedbackEmailText', array('feedback' => $feedback)))->setFrom($feedback['email'], $feedback['name'])->addTo(sfConfig::get('app_aFeedback_email_auto'))->setSubject($this->form->getValue('subject', 'New aBugReport submission'));
                 if ($screenshot = $this->form->getValue('screenshot')) {
                     $mail->createAttachment(file_get_contents($screenshot->getTempName()), $screenshot->getType());
                 }
                 $mail->send();
                 // A new form for a new submission
                 $this->form = new aFeedbackForm();
             } catch (Exception $e) {
                 $this->logMessage('Request email failed: ' . $e->getMessage(), 'err');
                 $this->failed = true;
                 return 'Success';
             }
             $this->getUser()->setFlash('reportSubmittedBy', $feedback['name']);
             $this->redirect($feedback['section']);
         }
     }
 }
开发者ID:hashir,项目名称:UoA,代码行数:37,代码来源:BaseaFeedbackActions.class.php

示例5: sendContractStudent

 /**
  * Отправка договора слушателю.
  *
  * @param  string $user_email      Email пользователя.
  * @param  string $attachFilePath  Путь прикрепляемого файла.
  * @return
  */
 public function sendContractStudent($user_email, $attachFilePath)
 {
     /* Получаем заголовок и текст письма */
     $subject = $this->_getSubject(self::TYPE_CONTRACT);
     $message = $this->_getMessage(self::TYPE_CONTRACT);
     if (!empty($attachFilePath) && file_exists($attachFilePath)) {
         $attachment = $this->_mail->createAttachment(file_get_contents($attachFilePath));
         $attachment->type = self::TYPE_ATTACHMENT;
         $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
         $attachment->filename = self::ATTACHMENT_NAME;
     }
     return $this->_send($user_email, $subject, $message);
 }
开发者ID:vyrus,项目名称:remote-edu,代码行数:20,代码来源:Postman.php

示例6: enviaEmail

 public function enviaEmail($emails = null, $msg = null, $replyTo = null, $assunto = null, $anexos = null)
 {
     //Initialize needed variables
     $config = new Zend_Config_Ini(realpath(APPLICATION_PATH . '/../') . '/application/configs/constants.ini', 'constants');
     //SMTP server configuration
     $smtpConf = array('auth' => 'login', 'port' => $config->smtp->port, 'username' => $config->smtp->user, 'password' => $config->smtp->senha);
     if ($config->smtp->ssl) {
         $smtpConf['ssl'] = $config->smtp->ssl;
     }
     //$transport = new Zend_Mail_Transport_Smtp($config->smtp->host, $smtpConf);
     $transport = new Zend_Mail_Transport_Smtp('localhost');
     // monta Msg
     $messg = "";
     $aMsg = count($msg);
     for ($i = 0; $i < $aMsg; $i++) {
         $messg .= "<b>" . $msg[$i]['tipo'] . " </b> <span>" . $msg[$i]['msg'] . "</span><br/><br/>";
     }
     $content = file_get_contents(realpath(APPLICATION_PATH . '/../') . '/public/inc/email/padrao.php');
     $content = str_replace('{TEXTO}', $messg, $content);
     $content = str_replace('{LINKSITE}', $config->config->site_cliente, $content);
     $content = str_replace('{URLLOGO}', $config->config->url_logo, $content);
     $mail = new Zend_Mail('utf-8');
     $mail->setFrom($config->smtp->from, $config->smtp->from_name);
     if ($emails) {
         foreach ($emails as $each_recipient) {
             $mail->addTo($each_recipient);
         }
     }
     $mail->setSubject($assunto);
     $mail->setBodyHtml($content);
     if ($anexos) {
         foreach ($anexos as $value) {
             $informacao = pathinfo($value);
             $image_mime = image_type_to_mime_type(exif_imagetype($value));
             $attachment = $mail->createAttachment(file_get_contents($value));
             $attachment->type = $image_mime;
             $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
             $attachment->filename = $informacao['basename'];
         }
     }
     //Enviar
     $sent = true;
     try {
         $mail->send($transport);
     } catch (Exception $e) {
         $sent = false;
     }
     //Return boolean indicando ok ou nao
     return $sent;
 }
开发者ID:powman,项目名称:zfpadrao,代码行数:50,代码来源:AbstractController.php

示例7: testSendEmailWithAttachment

 /**
  * Test the transport sending an email with an attachment
  *
  * @return void
  */
 public function testSendEmailWithAttachment()
 {
     //Load the required dependencies
     require_once 'Zend/Mail.php';
     require_once 'App/Mail/Transport/AmazonSES.php';
     $mail = new Zend_Mail('utf-8');
     $transport = new App_Mail_Transport_AmazonSES(array('accessKey' => AMAZON_AWS_ACCESS_KEY, 'privateKey' => AMAZON_AWS_PRIVATE_KEY));
     $mail->setBodyText('Lorem Ipsum Dolo Sit Amet');
     $mail->setBodyHtml('Lorem Ipsum Dolo <b>Sit Amet</b>');
     $mail->setFrom(AMAZON_SES_FROM_ADDRESS, 'John Doe');
     $mail->addTo(AMAZON_SES_TO_ADDRESS);
     $mail->setSubject('Test email from Amazon SES with attachments');
     $mail->createAttachment(file_get_contents('resources/image.jpeg'), 'image/jpeg', Zend_Mime::DISPOSITION_INLINE, Zend_Mime::ENCODING_BASE64, 'image.jpeg');
     $mail->send($transport);
 }
开发者ID:nauw,项目名称:Amazon-SES-Zend-Mail-Transport,代码行数:20,代码来源:AmazonSESTest.php

示例8: _addAttachments

 /** Add attachments
  * @access protected
  * @todo test function
  * @param array $attachments
  * @throws Exception
  */
 protected function _addAttachments(array $attachments)
 {
     if (is_array($attachments)) {
         foreach ($attachments as $attach) {
             $filter = new Zend_Filter_BaseName();
             $file = file_get_contents($attach);
             $addition = $this->_mail->createAttachment($file);
             $addition->disposition = Zend_Mime::DISPOSITION_INLINE;
             $addition->encoding = Zend_Mime::ENCODING_BASE64;
             $addition->filename = $filter->filter($attach);
         }
     } else {
         throw new Exception('The attachment list is not an array.');
     }
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:21,代码来源:Mailer.php

示例9: indexAction

 public function indexAction()
 {
     $frmContact = new Contact_Form_Contact();
     if ($this->_request->isPost() && $frmContact->isValid($_POST)) {
         // get the posted data
         $sender = $frmContact->getValue('name');
         $email = $frmContact->getValue('email');
         $subject = $frmContact->getValue('subject');
         $message = $frmContact->getValue('message');
         // load the template
         $htmlMessage = $this->view->partial('templates/default.phtml', $frmContact->getValues());
         $mail = new Zend_Mail();
         // configure and create the SMTP connection
         $config = array('auth' => 'login', 'username' => 'myusername', 'password' => 'password');
         $transport = new Zend_Mail_Transport_Smtp('mail.server.com', $config);
         // set the subject
         $mail->setSubject($subject);
         // set the message's from address to the person who submitted the form
         $mail->setFrom($email, $sender);
         // for the sake of this example you can hardcode the recipient
         $mail->addTo('forrestlyman@gmail.com', 'webmaster');
         // add the file attachment
         $fileControl = $frmContact->getElement('attachment');
         if ($fileControl->isUploaded()) {
             $attachmentName = $fileControl->getFileName();
             $fileStream = file_get_contents($attachmentName);
             // create the attachment
             $attachment = $mail->createAttachment($fileStream);
             $attachment->filename = basename($attachmentName);
         }
         // it is important to provide a text only version in addition to the html message
         $mail->setBodyHtml($htmlMessage);
         $mail->setBodyText($message);
         //send the message, now using SMTP transport
         $result = $mail->send($transport);
         // inform the view with the status
         $this->view->messageProcessed = true;
         if ($result) {
             $this->view->sendError = false;
         } else {
             $this->view->sendError = true;
         }
     }
     $frmContact->setAction('/contact');
     $frmContact->setMethod('post');
     $this->view->form = $frmContact;
 }
开发者ID:mtaha1990,项目名称:onlineDR,代码行数:47,代码来源:IndexController.php

示例10: emailAction

 protected function emailAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper('layout')->disableLayout();
     $form = new Application_Form_Email();
     $smtpconfig = array('auth' => $this->_config->smtpauth, 'username' => $this->_config->smtpuser, 'password' => $this->_config->smtppass);
     $tr = new Zend_Mail_Transport_Smtp($this->_config->smtphost, $smtpconfig);
     Zend_Mail::setDefaultTransport($tr);
     $mail = new Zend_Mail();
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             $email = $form->getValue('email');
             $subject = $form->getValue('subject');
             $body = $form->getValue('body');
             $file = $formData['file'];
             $mail->setBodyHtml($body);
             $mail->setFrom($this->_config->mailfrom, $this->_config->fromname);
             $mail->addTo($email);
             $mail->addBcc("remzi.demen@deec.de");
             $mail->setSubject($subject);
             if ($file) {
                 $file = explode("|", $file);
                 $att = file_get_contents(APPLICATION_PATH . '/..' . $file[0]);
                 $at = $mail->createAttachment($att);
                 $at->filename = $file[1];
             }
             $mail->send();
             $mail = new Zend_Mail_Storage_Imap(array('host' => $this->_config->smtphost, 'user' => $this->_config->smtpuser, 'password' => $this->_config->smtppass));
             print_r($mail);
         } else {
             $form->populate($formData);
         }
     }
 }
开发者ID:dewawi,项目名称:dewawi,代码行数:35,代码来源:InvoiceController.php

示例11: SEND_SMTP_ZEND

 private function SEND_SMTP_ZEND()
 {
     try {
         loadLibrary("ZEND", "Zend_Mail");
         loadLibrary("ZEND", "Zend_Mail_Transport_Smtp");
         if (empty($this->MailText)) {
             $this->MailText = ">>";
         }
         if ($this->Account->Authentication == "No") {
             $config = array('port' => $this->Account->Port);
         } else {
             $config = array('auth' => 'login', 'username' => $this->Account->Username, 'password' => $this->Account->Password, 'port' => $this->Account->Port);
         }
         if (!empty($this->Account->SSL)) {
             $config['ssl'] = $this->Account->SSL == 1 ? 'SSL' : 'TLS';
         }
         $transport = new Zend_Mail_Transport_Smtp($this->Account->Host, $config);
         $mail = new Zend_Mail('UTF-8');
         $mail->setBodyText($this->MailText);
         if (empty($this->FakeSender)) {
             $mail->setFrom($this->Account->Email, $this->Account->SenderName);
         } else {
             $mail->setFrom($this->FakeSender, $this->FakeSender);
         }
         if (strpos($this->Receiver, ",") !== false) {
             $emails = explode(",", $this->Receiver);
             $add = false;
             foreach ($emails as $mailrec) {
                 if (!empty($mailrec)) {
                     if (!$add) {
                         $add = true;
                         $mail->addTo($mailrec, $mailrec);
                     } else {
                         $mail->addBcc($mailrec, $mailrec);
                     }
                 }
             }
         } else {
             $mail->addTo($this->Receiver, $this->Receiver);
         }
         $mail->setSubject($this->Subject);
         $mail->setReplyTo($this->ReplyTo, $name = null);
         if ($this->Attachments != null) {
             foreach ($this->Attachments as $resId) {
                 $res = getResource($resId);
                 $at = $mail->createAttachment(file_get_contents("./uploads/" . $res["value"]));
                 $at->type = 'application/octet-stream';
                 $at->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
                 $at->encoding = Zend_Mime::ENCODING_BASE64;
                 $at->filename = $res["title"];
             }
         }
         $mail->send($transport);
     } catch (Exception $e) {
         if ($this->TestIt) {
             throw $e;
         } else {
             handleError("111", $this->Account->Host . " send mail connection error: " . $e->getMessage(), "functions.global.inc.php", 0);
         }
         return 0;
     }
     return 1;
 }
开发者ID:bgabor,项目名称:RenaniaOpencart,代码行数:63,代码来源:objects.mail.inc.php

示例12: addAction

 public function addAction()
 {
     //
     // 		$ddl_support_type = Zend_Registry::get('ddl_support_type');
     //		$this->view->ddl_support_type = $ddl_support_type;
     $faqs = new Application_Model_Faqs();
     $ddl_support_type = $faqs->fetchCategoryItems(3);
     $this->view->ddl_support_type = $ddl_support_type;
     $error = null;
     $status = null;
     $uname = $this->user->username();
     $this->view->uname = $uname;
     if ($this->request->isPost()) {
         $support = new Application_Model_Support();
         $userid = $this->user->getId();
         $supportArray = array();
         $supportArray = array("name" => trim($this->request->name), "email" => trim($this->request->email), "contactnumber" => trim($this->request->contactnumber), "support_type" => trim($this->request->support_type), "subject" => trim($this->request->subject), "status_type" => trim($this->request->status_type), "message" => trim($this->request->message), "created_by" => $userid);
         //echo '<pre>dgdfgdf';print_r($this->request->getParam('name'));
         //echo '<pre>';print_r($supportArray);
         //echo '<pre>';print_r($_FILES);die;
         if ($support->add($userid, $supportArray)) {
             $status = 'Support Added';
         } else {
             $error = 'Support Error: ' . $support->getError() . mysql_error();
         }
         $bodyText = "New Support:\n\r";
         $bodyText .= "Name: " . $this->request->name . "\n\r";
         $bodyText .= "Contact Number: " . $this->request->contactnumber . "\n\r";
         $bodyText .= "Support Type: " . $this->request->support_type . "\n\r";
         $bodyText .= "Subject: " . $this->request->subject . "\n\r";
         $bodyText .= "Status: " . $this->request->status_type . "\n\r";
         $bodyText .= "Message: " . $this->request->message . "\n\r";
         $bodyText .= "Regards\n\r";
         $bodyText .= "Textmunication.com\n\r";
         $mail = new Zend_Mail();
         $mail->setBodyText($bodyText);
         $mail->setFrom($this->request->email, $this->request->name);
         $mail->addTo('support@textmunication.com', 'Textmunication.com');
         //$mail->addTo('amudha.muralikannan@jeevantechnologies.com', 'Textmunication.com');
         //$mail->addCc('wais@textmunication.com', 'Wais Asefi');
         $mail->setSubject('New Support');
         if (isset($_FILES['uploaded_files'])) {
             foreach ($_FILES['uploaded_files']['name'] as $key => $value) {
                 if (is_uploaded_file($_FILES['uploaded_files']['tmp_name'][$key]) && $_FILES['uploaded_files']['error'][$key] == 0 && $_FILES['uploaded_files']['size'][$key] < 1048576) {
                     $filename = $_FILES['uploaded_files']['name'][$key];
                     //$id = $this->user->getId();
                     //$filetype = $_FILES['uploaded_files']['size'][$key];
                     $lastid = $support->supportId($userid);
                     //echo '<pre>';print_r($_FILES);die;
                     $lastidValue = $lastid[0]['last'];
                     $filename = $lastidValue . '-' . $filename;
                     if (move_uploaded_file($_FILES['uploaded_files']['tmp_name'][$key], '../public/uploads/' . $filename)) {
                         $support = new Application_Model_Support();
                         //$userid = $this->user->getId();
                         $supportattach = $filename;
                         if ($support->supportAttach($supportattach, $lastidValue)) {
                             $at = $mail->createAttachment(file_get_contents('../public/uploads/' . $supportattach));
                             $at->filename = $supportattach;
                             $status = 'Support Added';
                         } else {
                             $error = 'Support Error: ' . $support->getError() . mysql_error();
                         }
                     } else {
                         $error = 'The file was not moved.';
                     }
                 } else {
                     $error = 'The file was not uploaded size greater then 1MB.';
                 }
             }
         }
         if ($mail->send()) {
             $status = 'Support Added and mail Sent';
         }
         $this->view->status = $status;
         $this->view->error = $error;
         //$action = 'list';
         //return $this->_forward('list',null,null,array(null));
         return $this->_redirect('support/list');
     }
 }
开发者ID:fniftaly,项目名称:Java-Selenium,代码行数:80,代码来源:SupportController.php

示例13: check

 /**
  * Observer called from cronjob to check if there are orders which have a specific status (BE config) between
  * yesterday 13.30 and today 13.30.
  * - Generate CSV file (def. in /var/export)
  * - Send via email
  * @author 	Manuel Neukum
  * @param	$observer	Observer object
  */
 public function check($observer)
 {
     Mage::log("Checking for new Orders", null, 'orderexport.log');
     // Load where to store the file
     $path = Mage::getStoreConfig('sales/export/path');
     if (empty($path)) {
         $path = 'var/report';
     }
     // Load the status description from the config
     $name_of_receiver = Mage::getStoreConfig('sales/export/recname');
     $mail_of_receiver = Mage::getStoreConfig('sales/export/recmail');
     if (empty($mail_of_receiver)) {
         $name_of_receiver = Mage::getStoreConfig('trans_email/ident_general/name');
         $mail_of_receiver = Mage::getStoreConfig('trans_email/ident_general/email');
     }
     // Load Status
     $filter_status = Mage::getStoreConfig('sales/export/filter_status');
     if (empty($filter_status)) {
         $filter_status = 'pending';
     }
     // Load the order collection with specified data
     $collection = Mage::getModel('sales/order')->getCollection();
     $collection->addAttributeToSelect('entity_id');
     $collection->addAttributeToSelect('increment_id');
     $collection->addAttributeToSelect('created_at');
     $collection->addAttributeToSelect('billing_name');
     $collection->addAttributeToSelect('shipping_name');
     $collection->addAttributeToSelect('status');
     $collection->addAttributeToSelect('*');
     // Define time period
     $yesterday = date('Y-m-d', strtotime('-1 days')) . ' 13:30:00';
     $today = date('Y-m-d') . ' 13:30:00';
     // and filter from yesterday 13.30 till today 13.30 and the status from the BE ( def pending )
     $collection->addAttributeToFilter('created_at', array("from" => $yesterday, "to" => $today, "datetime" => true));
     $collection->addAttributeToFilter('status', $filter_status);
     // only export if we have new orders
     if ($collection->count() > 0) {
         // prepare Header
         $content = "Bestellnummer,Bestellt am,Rechnung an,Versandname,Status\n";
         try {
             $i = 0;
             // Load the Data and Address for every order
             foreach ($collection as $order) {
                 $loadedOrder = Mage::getModel('sales/order')->load($order->getId());
                 $content .= $loadedOrder->getIncrementId() . ',';
                 $content .= $loadedOrder->getCreatedAt() . ',';
                 $content .= $loadedOrder->getBillingAddress()->getName() . ',';
                 $content .= $loadedOrder->getShippingAddress()->getName() . ',';
                 $content .= $loadedOrder->getStatus() . "\n";
                 $i++;
             }
             // Show total
             $content .= ",,,,\n";
             $content .= "Anzahl:,{$i},,,\n";
             // Write in File
             $date = new Zend_Date($today);
             $filename = "{$path}/orderexport__" . $date->toString('dd_MM_yyyy') . ".csv";
             // is folder writeable
             if (is_writable(getcwd())) {
                 $fp = fopen($filename, 'w');
                 fwrite($fp, $content);
                 fclose($fp);
                 Mage::log("{$i} order(s) in {$filename} successfully exported!!", null, 'orderexport.log');
                 // ### now we want to send the new file as email ###
                 $mail = new Zend_Mail();
                 $mail->setBodyText('siehe Anhang');
                 // Get the data from the store config (owner)
                 $mail->setFrom(Mage::getStoreConfig('trans_email/ident_general/email'), Mage::getStoreConfig('trans_email/ident_general/name'));
                 // Get the data from the orderexport config
                 $mail->addTo($mail_of_receiver, $name_of_receiver);
                 $mail->setSubject("Exportierte Bestellungen vom {$yesterday} - {$today}");
                 // Add the file as attachment
                 $att = $mail->createAttachment(file_get_contents($filename));
                 $att->type = 'text/csv';
                 $att->disposition = Zend_Mime::DISPOSITION_INLINE;
                 $att->encoding = Zend_Mime::ENCODING_BASE64;
                 $att->filename = $filename;
                 // Send
                 $mail->send();
                 Mage::log("Sending Mail to {$mail_of_receiver}", null, 'orderexport.log');
             } else {
                 Mage::log('No write permission in folder', null, 'orderexport.log');
             }
         } catch (Exception $e) {
             Mage::log('Exception: ' . $e->getMessage(), null, 'orderexport.log');
         }
     } else {
         Mage::log('There are no new orders with your status ' . $filter_status, null, 'orderexport.log');
     }
 }
开发者ID:stefas1,项目名称:mage-order-export,代码行数:98,代码来源:Observer.php

示例14: send

	function send()
	{
		global $config;
		//echo "export show data";
		
		// Create authentication with SMTP server
		$authentication = array();
		if($config->email->smtp_auth == true) {
			$authentication = array(
				'auth' => 'login',
				'username' => $config->email->username,
				'password' => $config->email->password,
				'ssl' => $config->email->secure,
				'port' => $config->email->smtpport
				);
		}
		$transport = new Zend_Mail_Transport_Smtp($config->email->host, $authentication);

		// Create e-mail message
		$mail = new Zend_Mail('utf-8');
		$mail->setType(Zend_Mime::MULTIPART_MIXED);
		$mail->setBodyText($this->notes);
		$mail->setBodyHTML($this->notes);
		$mail->setFrom($this->from, $this->from_friendly);

		$to_addresses = preg_split('/\s*[,;]\s*/', $this->to);
		if (!empty($to_addresses)) {
			foreach ($to_addresses as $to) {
			    $mail->addTo($to);
		   }
		}
		if (!empty($this->bcc)) {
		    $bcc_addresses = preg_split('/\s*[,;]\s*/', $this->bcc);
		foreach ($bcc_addresses as $bcc) {
				$mail->addBcc($bcc);
			}
		}
		$mail->setSubject($this->subject);

        if($this->attachment)
        {
            // Create attachment
            #$spc2us_pref = str_replace(" ", "_", $preference[pref_inv_wording]);
            $content = file_get_contents('./tmp/cache/'.$this->attachment);
            $at = $mail->createAttachment($content);
            $at->type = 'application/pdf';
            $at->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
            $at->filename = $this->attachment;
        }
		// Send e-mail through SMTP
		try {
			$mail->send($transport);
		} catch(Zend_Mail_Protocol_Exception $e) {
			echo '<strong>Zend Mail Protocol Exception:</strong> ' .  $e->getMessage();
			exit;
		}

		// Remove temp invoice
		unlink("./tmp/cache/$this->attachment");

		switch ($this->format)
		{
			case "invoice":
			{

				// Create succes message
				$message  = "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?module=invoices&amp;view=manage\">";
				$message .= "<br />$this->attachment has been emailed";

				break;
			}	
			case "statement":
			{

				// Create succes message
				$message  = "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?module=statement&amp;view=index\">";
				$message .= "<br />$this->attachment has been emailed";

				break;
			}	
			case "cron":
			{

				// Create succes message
				$message .= "<br />Cron email for today has been sent";

				break;
			}
			case "cron_invoice":
			{

				// Create succes message
				$message .= "$this->attachment has been emailed";

				break;
			
			}	
		}	


//.........这里部分代码省略.........
开发者ID:CalhounGaming,项目名称:simpleinvoices,代码行数:101,代码来源:email.php

示例15: sending

 public function sending(Zend_Form $form)
 {
     $request = Zend_Controller_Front::getInstance()->getRequest();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             //campos e valores
             $value = $form->getValues();
             //chaves de campos
             $key = array_keys($form->getValues());
             //chaves de campos file
             $key_file = array_keys($_FILES);
             //concatena chaves e valores do form
             if (!$this->message) {
                 $msg = "<table style='width:500px'>";
                 for ($i = 0; $i < count($key); $i++) {
                     $msg .= "<tr>";
                     $msg .= "<th style='padding:5px; background:#f1f1f1; font-weight:bold; border:1px solid #ccc; text-align:right'>";
                     $msg .= ucwords($key[$i]);
                     $msg .= "</th>";
                     $msg .= "<td style='padding:5px; border:1px solid #ccc'>";
                     $msg .= nl2br($value[$key[$i]]);
                     $msg .= "</td>";
                     $msg .= "</tr>";
                 }
                 $msg .= "</table>";
                 $this->message = $msg;
             }
             //envia email
             $mail = new Zend_Mail('utf-8');
             $mail->setFrom($this->from, $this->name);
             $mail->addTo($this->to);
             $mail->addBcc($this->bcc);
             $mail->addCc($this->cc);
             $mail->setBodyHtml($this->message);
             $mail->setSubject($this->assunto);
             for ($x = 0; $x < count($_FILES); $x++) {
                 //recebe nome de campos file
                 $file = $_FILES[$key_file[$x]];
                 //verifica se recebeu anexo
                 if ($file['error'] == 0) {
                     $filetmp = $file['tmp_name'];
                     $filename = $file['name'];
                     $filetype = $file['type'];
                     $filesize = $file['size'];
                     //anexo(s)
                     $mail->createAttachment(file_get_contents($filetmp), $filetype, Zend_Mime::DISPOSITION_INLINE, Zend_Mime::ENCODING_BASE64, $filename);
                 }
             }
             if (!empty($this->smtp) and !empty($this->username) and !empty($this->password)) {
                 //configuração smtp
                 $config = array('auth' => $this->auth, 'username' => $this->username, 'password' => $this->password, 'ssl' => $this->ssl, 'port' => $this->port);
                 //função smtp
                 $mailTransport = new Zend_Mail_Transport_Smtp($this->smtp, $config);
                 $mail->send($mailTransport);
             } else {
                 //envio normal
                 $mail->send();
             }
             //retorna para página informada
             header("location: " . $this->return);
         }
     }
 }
开发者ID:alissonpirola,项目名称:site-drandre,代码行数:63,代码来源:RGBSendMail.php


注:本文中的Zend_Mail::createAttachment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。