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


PHP Zend_Mail::setType方法代码示例

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


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

示例1: _sendNewCommentEmail

 /**
  * Send email notification to moderators when a new comment is posted
  * 
  * @todo move logic to model / library class
  * 
  * @param HumanHelp_Model_Comment $comment
  * @param HumanHelp_Model_Page $page
  */
 public function _sendNewCommentEmail(HumanHelp_Model_Comment $comment, HumanHelp_Model_Page $page)
 {
     $config = Zend_Registry::get('config');
     $emailTemplate = new Zend_View();
     $emailTemplate->setScriptPath(APPLICATION_PATH . '/views/emails');
     $emailTemplate->addHelperPath(APPLICATION_PATH . '/views/helpers', 'HumanHelp_View_Helper_');
     $emailTemplate->setEncoding('UTF-8');
     $emailTemplate->comment = $comment;
     $emailTemplate->page = $page;
     $emailTemplate->baseUrl = 'http://' . $_SERVER['HTTP_HOST'] . $this->view->baseUrl;
     $bodyHtml = $emailTemplate->render('newComment.phtml');
     $bodyText = $emailTemplate->render('newComment.ptxt');
     $mail = new Zend_Mail();
     $mail->setType(Zend_Mime::MULTIPART_ALTERNATIVE)->setBodyHtml($bodyHtml, 'UTF-8')->setBodyText($bodyText, 'UTF-8')->setSubject("New comment on '{$page->getTitle()}' in '{$page->getBook()->getTitle()}'")->setFrom($config->fromAddress, $config->fromName);
     if (is_object($config->notifyComments)) {
         foreach ($config->notifyComments->toArray() as $rcpt) {
             $mail->addTo($rcpt);
         }
     } else {
         $mail->addTo($config->notifyComments);
     }
     if ($config->smtpServer) {
         $transport = new Zend_Mail_Transport_Smtp($config->smtpServer, $config->smtpOptions->toArray());
     } else {
         $transport = new Zend_Mail_Transport_Sendmail();
     }
     $mail->send($transport);
 }
开发者ID:shevron,项目名称:HumanHelp,代码行数:36,代码来源:IndexController.php

示例2: email

 /**
  * Send email to user
  *
  * @param string $emailAddress
  * @param string $subject   the subject string
  * @param string $message   the message string
  * @return  object/boolean  if failed will return false otherwise boolean false will be returned.
  * @example
  *          $e = new RM_Module_Emailnotifications();
  *          $result = $e->email(RM_User_Row $user, "This is the email subject", "This is the message body");
  *
  */
 public function email($emailAddress, $subject, $message)
 {
     $configModel = new RM_Config();
     $mail = new Zend_Mail('UTF-8');
     $mail->setType(Zend_Mime::MULTIPART_MIXED);
     $mail->addTo($emailAddress);
     $mail->setFrom($configModel->getValue('rm_config_email_settings_mailfrom'), $configModel->getValue('rm_config_email_settings_fromname'));
     $mail->setBodyHtml($message);
     $mail->setSubject($subject);
     $emailType = $configModel->getValue('rm_config_email_settings_mailer');
     try {
         if ($emailType == 'PHP') {
             return $mail->send();
         } else {
             $smtpConfig = array('auth' => 'Login', 'username' => $configModel->getValue('rm_config_email_settings_smtpuser'), 'password' => $configModel->getValue('rm_config_email_settings_smtppass'), 'port' => $configModel->getValue('rm_config_email_settings_smtpport'));
             if ($configModel->getValue('rm_config_email_settings_smtpsecure') != "") {
                 $smtpConfig['ssl'] = strtolower($configModel->getValue('rm_config_email_settings_smtpsecure'));
             }
             return $mail->send(new Zend_Mail_Transport_Smtp($configModel->getValue('rm_config_email_settings_smtphost'), $smtpConfig));
         }
     } catch (Zend_Mail_Exception $e) {
         RM_Log::toLog("Notification error: " . $e->getMessage());
         return false;
     }
 }
开发者ID:laiello,项目名称:resmania,代码行数:37,代码来源:EmailNotifications.php

示例3: handle

 /**
  * @param string $fromTitle
  * @param string $fromMail
  * @param string $toEmail
  * @param array $recipientCC
  * @param array $recipientBCC
  * @param string $subject
  * @param string $body
  * @param string $attachments
  * @param string $smtpHost
  * @param string $smtpPort
  * @param string $serverLogin
  * @param string $serverPassword
  * @param string $charCode
  * @param boolean $isHtml
  * @return type
  */
 public function handle($fromTitle, $fromMail, $toEmail, array $recipientCC, array $recipientBCC, $subject, $body, $attachments, $smtpHost = null, $smtpPort = null, $serverLogin = null, $serverPassword = null, $charCode = 'UTF-8', $isHtml = false, $replyto = null)
 {
     if ($smtpHost) {
         $params = array('name' => 'ZendMailHandler', 'port' => $smtpPort);
         if ($serverLogin) {
             $params['auth'] = 'login';
             $params['username'] = $serverLogin;
             $params['password'] = $serverPassword;
         }
         $transport = new Zend_Mail_Transport_Smtp($smtpHost, $params);
     } else {
         $transport = new Zend_Mail_Transport_Sendmail(array('name' => 'ZendMailHandler'));
     }
     $mail = new Zend_Mail($charCode);
     $mail->setFrom($fromMail, $fromTitle)->addTo($toEmail)->setSubject($subject);
     if (!empty($recipientCC)) {
         $mail->addCc($recipientCC);
     }
     if (!empty($recipientBCC)) {
         $mail->addBcc($recipientBCC);
     }
     //$mail->setReturnPath($replyto);
     if (!empty($replyto)) {
         $mail->setReplyTo($replyto);
     }
     if ($isHtml) {
         $mail->setBodyHtml($body);
     } else {
         $mail->setBodyText($body);
     }
     if (is_object($attachments) && $attachments->areAttachments()) {
         $mail->setType(Zend_Mime::MULTIPART_RELATED);
         $attachments->handle($mail);
     }
     if ($mail->send($transport)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:knatorski,项目名称:SMS,代码行数:57,代码来源:ZendMail.php

示例4: postAction

 public function postAction()
 {
     $post = $this->getRequest()->getPost();
     try {
         $mail = new Zend_Mail();
         $mail->setType(Zend_Mime::MULTIPART_RELATED);
         $mail->setBodyHtml('email: ' . $post['email'] . '<br />name: ' . $post['name'] . '<br />message:<br />' . $post['feedback']);
         $mail->setFrom($post['email'], $post['name']);
         #$mail->setFrom('no-reply@fashioneyewear.co.uk', 'fashioneyewear');
         $mail->addTo('nathan@fashioneyewear.co.uk', '');
         $mail->addTo('tejjohal@gmail.com', '');
         $mail->setSubject(Mage::helper('contacts')->__('New feedback'));
         $mail->send();
         Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your feedback was submitted.'));
         $this->_redirectReferer();
         return;
     } catch (Exception $e) {
         Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later.'));
         $this->_redirectReferer();
         return;
     }
 }
开发者ID:CherylMuniz,项目名称:fashion,代码行数:22,代码来源:IndexController.php

示例5: mail

 function mail($data)
 {
     $mail = new Zend_Mail('utf-8');
     $mail->setType(Zend_Mime::MULTIPART_ALTERNATIVE);
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
     $body = $this->view->partial('mail/frame.phtml', array('message' => @$data['body'] ? $data['body'] : $this->view->partial('mail/' . $data['view'] . '.phtml', $data)));
     preg_match_all('/src\\=\\"\\/(img|upload\\/mce\\/image)\\/([^\\"]+)\\"/si', $body, $res);
     if (@$res[1]) {
         $r = array();
         foreach ($res[1] as $k => $v) {
             $fn = PUBLIC_PATH . '/' . $res[1][$k] . '/' . $res[2][$k];
             $s = getimagesize($fn);
             if ($s) {
                 $cid = md5($res[1][$k] . '/' . $res[2][$k]);
                 $at = $mail->createAttachment(file_get_contents($fn), $s['mime'], Zend_Mime::DISPOSITION_INLINE, Zend_Mime::ENCODING_BASE64);
                 $at->id = $cid;
                 $r[] = 'src="cid:' . $cid . '"';
             } else {
                 $r[] = $res[0][$k];
             }
         }
         $body = str_ireplace($res[0], $r, $body);
     }
     preg_match_all('/href\\=\\"\\/upload\\/mce\\/file\\/([^\\"]+)\\"/si', $body, $res);
     if (@$res[1]) {
         $r = array();
         foreach ($res[1] as $k => $v) {
             $fn = PUBLIC_PATH . '/upload/mce/file/' . $res[1][$k];
             $s = file_exists($fn);
             if ($s) {
                 $cid = md5('upload/mce/file/' . $res[1][$k]);
                 $at = $mail->createAttachment(file_get_contents($fn), Zend_Mime::TYPE_OCTETSTREAM, Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, basename($fn));
                 $at->id = $cid;
                 $r[] = 'href="cid:' . $cid . '"';
             } else {
                 $r[] = $res[0][$k];
             }
         }
         $body = str_ireplace($res[0], $r, $body);
     }
     $mail->setBodyHtml($body);
     $fm = $this->view->txt('site_mail');
     $from = @$data['from'] ? $data['from'] : $this->view->txt('site_mail');
     $to = @$data['to'] ? $data['to'] : $this->view->txt('site_mail');
     $to = preg_split('/(\\;|\\,)/i', $to);
     $reply_to = @$data['reply_to'];
     $from_name = @$data['from_name'] ? $data['from_name'] : ($from == $fm ? $this->view->txt('site_title') : $from);
     if ($reply_to) {
         $mail->setReplyTo($reply_to, $from_name);
     }
     $mail->setFrom($from, $from_name);
     $tn = @$data['to_name'] ? $data['to_name'] : $to;
     foreach ($to as $n => $el) {
         $el = trim($el);
         if (!$el) {
             continue;
         }
         $tn_el = is_array($tn) ? isset($tn[$n]) ? $tn[$n] : @$tn[0] : $tn;
         $mail->addTo($el, $tn_el);
     }
     if (@$data['subject_full']) {
         $mail->setSubject($data['subject_full']);
     } else {
         $mail->setSubject($this->view->txt('site_title') . ($data['subject'] ? ' — ' . $data['subject'] : ''));
     }
     $ok = false;
     try {
         $tr = null;
         $bt = Zend_Controller_Front::getInstance()->getParam('bootstrap');
         if ($bt) {
             $config = $bt->getOptions();
             if (@$config['mail']) {
                 if (@$config['mail']['transports'] && @$config['mail']['transports']['transport']) {
                     foreach ($config['mail']['transports']['transport'] as $k => $v) {
                         $class = 'Zend_Mail_Transport_' . ucfirst($v);
                         $tr = new $class($config['mail']['transports'][$v]['host'][$k], array('host' => $config['mail']['transports'][$v]['host'][$k], 'port' => $config['mail']['transports'][$v]['port'][$k], 'auth' => $config['mail']['transports'][$v]['auth'][$k], 'username' => $config['mail']['transports'][$v]['username'][$k], 'password' => $config['mail']['transports'][$v]['password'][$k], 'ssl' => $config['mail']['transports'][$v]['ssl'][$k]));
                         try {
                             $mail->send($tr);
                             $ok = true;
                             break;
                         } catch (Exception $e) {
                             //$ok = false;
                             //@file_put_contents(DATA_PATH.'/mail-'.time().microtime(true).'.txt', var_export($e, 1));
                         }
                     }
                     $tr = null;
                 } else {
                     if (@$config['mail']['transport']) {
                         $k = $config['mail']['transport'];
                         if (@$config['mail'][$k] && @$config['mail'][$k]['host']) {
                             try {
                                 $class = 'Zend_Mail_Transport_' . ucfirst($k);
                                 $tr = new $class($config['mail']['smtp']['host'], $config['mail'][$k]);
                             } catch (Exception $e) {
                                 $tr = null;
                                 //$ok = false;
                             }
                         }
                     }
                 }
//.........这里部分代码省略.........
开发者ID:s-kalaus,项目名称:zkernel,代码行数:101,代码来源:Mail.php

示例6: 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

示例7: _buildBody

 /**
  * Generate MIME compliant message from the current configuration
  *
  * If both a text and HTML body are present, generates a
  * multipart/alternative Zend_Mime_Part containing the headers and contents
  * of each. Otherwise, uses whichever of the text or HTML parts present.
  *
  * The content part is then prepended to the list of Zend_Mime_Parts for
  * this message.
  *
  * @return void
  */
 protected function _buildBody()
 {
     //        if (($text = $this->_mail->getBodyText())
     //            && ($html = $this->_mail->getBodyHtml()))
     //
     $text = $this->_mail->getBodyText();
     $html = $this->_mail->getBodyHtml();
     $htmlAttachments = $this->_mail->getHtmlRelatedAttachments();
     $htmlAttachmentParts = $htmlAttachments->getParts();
     $hasHtmlRelatedParts = count($htmlAttachmentParts);
     if ($text && $html || $html && $hasHtmlRelatedParts && count($this->_parts)) {
         // Generate unique boundary for multipart/alternative
         $mime = new Zend_Mime(null);
         $boundaryLine = $mime->boundaryLine($this->EOL);
         $boundaryEnd = $mime->mimeEnd($this->EOL);
         //            $text->disposition = false;
         $html->disposition = false;
         //            $body = $boundaryLine
         //                  . $text->getHeaders($this->EOL)
         //                  . $this->EOL
         //                  . $text->getContent($this->EOL)
         //                  . $this->EOL
         //                  . $boundaryLine
         //                  . $html->getHeaders($this->EOL)
         if ($hasHtmlRelatedParts) {
             $message = new Zend_Mime_Message();
             array_unshift($htmlAttachmentParts, $html);
             $message->setParts($htmlAttachmentParts);
             $htmlMime = $htmlAttachments->getMime();
             $message->setMime($htmlMime);
             $html = new Zend_Mime_Part($message->generateMessage($this->EOL, false));
             $html->boundary = $htmlMime->boundary();
             $html->type = Zend_Mime::MULTIPART_RELATED;
             $html->encoding = null;
         }
         $body = $boundaryLine;
         if ($text) {
             $text->disposition = false;
             $body .= $text->getHeaders($this->EOL) . $this->EOL . $text->getContent($this->EOL) . $this->EOL . $boundaryLine;
         }
         $body .= $html->getHeaders($this->EOL) . $this->EOL . $html->getContent($this->EOL) . $this->EOL . $boundaryEnd;
         $mp = new Zend_Mime_Part($body);
         $mp->type = Zend_Mime::MULTIPART_ALTERNATIVE;
         $mp->boundary = $mime->boundary();
         $this->_isMultipart = true;
         // Ensure first part contains text alternatives
         array_unshift($this->_parts, $mp);
         // Get headers
         $this->_headers = $this->_mail->getHeaders();
         return;
     }
     // If not multipart, then get the body
     if (false !== ($body = $this->_mail->getBodyHtml())) {
         array_unshift($this->_parts, $body);
         if ($hasHtmlRelatedParts) {
             $this->_mail->setType(Zend_Mime::MULTIPART_RELATED);
             foreach ($htmlAttachmentParts as $part) {
                 $this->_parts[] = $part;
             }
         }
     } elseif (false !== ($body = $this->_mail->getBodyText())) {
         array_unshift($this->_parts, $body);
     }
     if (!$body) {
         /**
          * @see Zend_Mail_Transport_Exception
          */
         require_once 'Zend/Mail/Transport/Exception.php';
         throw new Zend_Mail_Transport_Exception('No body specified');
     }
     // Get headers
     $this->_headers = $this->_mail->getHeaders();
     $headers = $body->getHeadersArray($this->EOL);
     foreach ($headers as $header) {
         // Headers in Zend_Mime_Part are kept as arrays with two elements, a
         // key and a value
         $this->_headers[$header[0]] = array($header[1]);
     }
 }
开发者ID:,项目名称:,代码行数:91,代码来源:

示例8: testTypeAccessor

 public function testTypeAccessor()
 {
     $mail = new Zend_Mail();
     $this->assertNull($mail->getType());
     $mail->setType(Zend_Mime::MULTIPART_ALTERNATIVE);
     $this->assertEquals(Zend_Mime::MULTIPART_ALTERNATIVE, $mail->getType());
     $mail->setType(Zend_Mime::MULTIPART_RELATED);
     $this->assertEquals(Zend_Mime::MULTIPART_RELATED, $mail->getType());
     try {
         $mail->setType('text/plain');
         $this->fail('Invalid Zend_Mime type should throw an exception');
     } catch (Exception $e) {
     }
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:14,代码来源:MailTest.php


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