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


PHP Mail_mimePart::encode方法代码示例

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


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

示例1: sendMMS

 public function sendMMS($senderAddress, $addressList, $message, $attachments, $senderName, $clientCorrelator, $notifyURL, $callbackData)
 {
     $sendMMSResponse = null;
     if ($senderAddress && $addressList && ($message || $attachments)) {
         if (!is_null($this->endpoint) && property_exists($this->endpoint, 'SendSMS')) {
             $url = $this->endpoint->getSendMMSEndpoint();
         } else {
             $url = 'http://localhost:8080/oneapiserver/SendMMSService/1/messaging/outbound/{senderAddress}/requests';
         }
         $url = str_replace('{senderAddress}', urlencode($senderAddress), $url);
         $formParameters = new FormParameters();
         $formParameters->put("senderAddress", $senderAddress);
         for ($i = 0; $i < count($addressList); $i++) {
             $formParameters->put("address", $addressList[$i]);
         }
         $formParameters->put("message", $message);
         $formParameters->put("clientCorrelator", $clientCorrelator);
         $formParameters->put("notifyURL", $notifyURL);
         $formParameters->put("senderName", $senderName);
         $formParameters->put("callbackData", $callbackData);
         $params = array();
         $params['content_type'] = 'multipart/mixed';
         $requestBody = new Mail_mimePart('', $params);
         $params['content_type'] = 'application/x-www-form-urlencoded';
         //$params['encoding']     = '8bit';
         $params['disposition'] = 'form-data; name="root-fields"';
         $text = $requestBody->addSubPart($formParameters->encodeParameters(), $params);
         error_log('Processing attachments');
         if ($attachments && is_array($attachments) && count($attachments) > 0) {
             for ($i = 0; $i < count($attachments); $i++) {
                 error_log('Processing file ' . $i);
                 $file = $attachments[$i];
                 if ($file && is_array($file) && isset($file['error']) && $file['error'] == UPLOAD_ERR_OK) {
                     error_log('Have attachment name=' . $file['name'] . ' type=' . $file['type'] . ' size=' . $file['size']);
                     $params['content_type'] = $file['type'];
                     $params['encoding'] = 'base64';
                     $params['disposition'] = 'form-data; name="' . $file['name'] . '"';
                     $contents = file_get_contents($file['tmp_name']);
                     $attach =& $requestBody->addSubPart($contents, $params);
                 }
             }
         }
         $content = $requestBody->encode();
         $contentType = $content['headers']['Content-Type'];
         $data = $content['body'];
         error_log('Generated...\\n' . print_r($content, true));
         $request = new JSONRequest($url, $this->username, $this->password, 'POST', null, $contentType, $data);
         $response = $request->execute();
         if ($response->getResponseBody()) {
             $jsondata = json_decode($response->getResponseBody());
         }
         error_log("MMSSend::sendMMS response=" . print_r($response, true));
         error_log("MMSSend::sendMMS jsondata=" . print_r($jsondata, true));
         $responseInfo = $response->getResponseInfo();
         $location = $response->getLocation();
         $sendMMSResponse = new MMSSendResponse($responseInfo["http_code"], $responseInfo["content_type"], $location, $jsondata);
         error_log("MMSSend::sendMMS sendMMSResponse=" . print_r($sendMMSResponse, true));
     }
     return $sendMMSResponse;
 }
开发者ID:GSMADeveloper,项目名称:GSMA-OneAPI,代码行数:60,代码来源:MMSSend.php

示例2: encodeMimeMultipart

 /**
  * Given array of MIME parts in raw string, this function converts them into MIME
  * representation. 
  * 
  * @param array $bodyPartContents The MIME body parts.
  * 
  * @return array Returns array with two elements 'headers' and 'body' which
  * represents the MIME message.
  */
 public function encodeMimeMultipart($bodyPartContents)
 {
     $count = count($bodyPartContents);
     $mimeType = Resources::MULTIPART_MIXED_TYPE;
     $batchGuid = strtolower(trim(com_create_guid(), '{}'));
     $batchId = sprintf('batch_%s', $batchGuid);
     $contentType1 = array('content_type' => "{$mimeType}");
     $changeSetGuid = strtolower(trim(com_create_guid(), '{}'));
     $changeSetId = sprintf('changeset_%s', $changeSetGuid);
     $contentType2 = array('content_type' => "{$mimeType}; boundary={$changeSetId}");
     $options = array('encoding' => 'binary', 'content_type' => Resources::HTTP_TYPE);
     // Create changeset MIME part
     $changeSet = new \Mail_mimePart();
     for ($i = 0; $i < $count; $i++) {
         $changeSet->addSubpart($bodyPartContents[$i], $options);
     }
     // Encode the changeset MIME part
     $changeSetEncoded = $changeSet->encode($changeSetId);
     // Create the batch MIME part
     $batch = new \Mail_mimePart(Resources::EMPTY_STRING, $contentType1);
     // Add changeset encoded to batch MIME part
     $batch->addSubpart($changeSetEncoded['body'], $contentType2);
     // Encode batch MIME part
     $batchEncoded = $batch->encode($batchId);
     return $batchEncoded;
 }
开发者ID:pankajadhyapak,项目名称:um_new,代码行数:35,代码来源:MimeReaderWriter.php

示例3: send

 public function send()
 {
     $to = $this->getSetting('to', '');
     $from = $this->getSetting('from', '');
     $subject = $this->getSetting('subject', '');
     $encoding = $this->getSetting('encoding', '');
     $body = $this->getSetting('content', '');
     $error = '';
     $crlf = '';
     $params = array();
     $params['host'] = $this->getSetting('server', '');
     $params['auth'] = $this->getSetting('auth', true);
     $params['username'] = $this->getSetting('user', '');
     $params['password'] = $this->getSetting('password', '');
     $params['port'] = $this->getSetting('port', '587');
     $headers = array();
     $headers['To'] = 'To: ' . $to;
     $headers['From'] = 'From: ' . $from;
     $headers['Subject'] = $subject;
     $htmlparams = array('charset' => 'utf-8', 'content_type' => 'text/html', 'encoding' => 'quoted/printable');
     $email = new Mail_mimePart('', array('content_type' => 'multipart/alternative'));
     $htmlmime = $email->addSubPart($this->getTemplate(), $htmlparams);
     $final = $email->encode();
     $final['headers'] = array_merge($final['headers'], $headers);
     $smtp = Mail::factory('smtp', $params);
     $mail = $smtp->send($to, $final['headers'], $final['body']);
     if (PEAR::isError($mail)) {
         $error = $mail->getMessage();
     }
     return $error;
 }
开发者ID:salamonrafal,项目名称:PHPFramework,代码行数:31,代码来源:com.salamon.mail.php

示例4: sendTextMail

 public function sendTextMail(PrmPerson $to, $Header, $Body, PrmPerson $ReplyTo = null)
 {
     $headers['To'] = $to->getForMailUser();
     $headers['From'] = $this->_From;
     $headers['Return-Path'] = $this->_From;
     if ($ReplyTo != null) {
         $headers['Reply-To'] = $ReplyTo->getForMailUser();
     }
     $headers['Subject'] = $Header;
     $headers['Errors-To'] = '<<a href="mailto:errors@example.com">errors@example.com</a>>';
     $headers['MIME-Version'] = '1.0';
     $textparams = array('charset' => 'utf-8', 'content_type' => 'text/plain', 'encoding' => 'quoted/printable');
     $email = new Mail_mimePart('', array('content_type' => 'multipart/alternative'));
     $textmime = $email->addSubPart($Body, $textparams);
     $final = $email->encode();
     $final['headers'] = array_merge($final['headers'], $headers);
     $smtp_params = array();
     $smtp_params['host'] = $this->_Host;
     $smtp_params['port'] = $this->_Port;
     $smtp_params['auth'] = true;
     $smtp_params['username'] = $this->_UserName;
     $smtp_params['password'] = $this->_Password;
     $smtp_params['debug'] = false;
     //$smtp_params['persist'] = TRUE;
     $mail =& Mail::factory('smtp', $smtp_params);
     $status = $mail->send($to->getForMailUser(), $final['headers'], $final['body']);
     if (PEAR::isError($status)) {
         print $status->getMessage();
         exit;
         return false;
     } else {
         return true;
     }
 }
开发者ID:makinuk,项目名称:Qcore,代码行数:34,代码来源:CntMail.php

示例5: array

 function _makeMimeMessage($xml, $encoding = SOAP_DEFAULT_ENCODING)
 {
     if (!@(include_once 'Mail/mimePart.php')) {
         return $this->_raiseSoapFault('MIME messages are unsupported, the Mail_Mime package is not installed');
     }
     // Encode any attachments.  See http://www.w3.org/TR/SOAP-attachments
     // Now we have to mime encode the message.
     $params = array('content_type' => 'multipart/related; type="text/xml"');
     $msg = new Mail_mimePart('', $params);
     // Add the xml part.
     $params['content_type'] = 'text/xml';
     $params['charset'] = $encoding;
     $params['encoding'] = 'base64';
     $msg->addSubPart($xml, $params);
     // Add the attachements
     for ($i = 0, $c = count($this->_attachments); $i < $c; ++$i) {
         $msg->addSubPart($this->_attachments[$i]['body'], $this->_attachments[$i]);
     }
     return $msg->encode();
 }
开发者ID:rolwi,项目名称:koala,代码行数:20,代码来源:Base.php

示例6: get

 /**
  * Builds the multipart message.
  *
  * @param array    $params    Build parameters that change the way the email
  *                            is built. Should be associative. See $_build_params.
  * @param resource $filename  Output file where to save the message instead of
  *                            returning it
  * @param boolean  $skip_head True if you want to return/save only the message
  *                            without headers
  *
  * @return mixed The MIME message content string, null or PEAR error object
  */
 public function get($params = null, $filename = null, $skip_head = false)
 {
     if (isset($params)) {
         while (list($key, $value) = each($params)) {
             $this->build_params[$key] = $value;
         }
     }
     $this->checkParams();
     if ($this->type == self::PGP_SIGNED) {
         $params = array('preamble' => "This is an OpenPGP/MIME signed message (RFC 4880 and 3156)", 'content_type' => "multipart/signed; micalg=pgp-sha1; protocol=\"application/pgp-signature\"", 'eol' => $this->build_params['eol']);
         $message = new Mail_mimePart('', $params);
         if (!empty($this->body)) {
             $headers = $this->message->headers();
             $params = array('content_type' => $headers['Content-Type']);
             if ($headers['Content-Transfer-Encoding']) {
                 $params['encoding'] = $headers['Content-Transfer-Encoding'];
             }
             $message->addSubpart($this->body, $params);
         }
         if (!empty($this->signature)) {
             $message->addSubpart($this->signature, array('filename' => 'signature.asc', 'content_type' => 'application/pgp-signature', 'disposition' => 'attachment', 'description' => 'OpenPGP digital signature'));
         }
     } else {
         if ($this->type == self::PGP_ENCRYPTED) {
             $params = array('preamble' => "This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)", 'content_type' => "multipart/encrypted; protocol=\"application/pgp-encrypted\"", 'eol' => $this->build_params['eol']);
             $message = new Mail_mimePart('', $params);
             $message->addSubpart('Version: 1', array('content_type' => 'application/pgp-encrypted', 'description' => 'PGP/MIME version identification'));
             $message->addSubpart($this->encrypted, array('content_type' => 'application/octet-stream', 'description' => 'PGP/MIME encrypted message', 'disposition' => 'inline', 'filename' => 'encrypted.asc'));
         }
     }
     // Use saved boundary
     if (!empty($this->build_params['boundary'])) {
         $boundary = $this->build_params['boundary'];
     } else {
         $boundary = null;
     }
     // Write output to file
     if ($filename) {
         // Append mimePart message headers and body into file
         $headers = $message->encodeToFile($filename, $boundary, $skip_head);
         if ($this->isError($headers)) {
             return $headers;
         }
         $this->headers = array_merge($this->headers, $headers);
         return null;
     } else {
         $output = $message->encode($boundary, $skip_head);
         if ($this->isError($output)) {
             return $output;
         }
         $this->headers = array_merge($this->headers, $output['headers']);
         return $output['body'];
     }
 }
开发者ID:jgtoriginal,项目名称:roundcubemail,代码行数:66,代码来源:enigma_mime_message.php

示例7: eF_mail_multipart

 protected function eF_mail_multipart($sender, $recipient, $subject, $textbody, $calendarbody, $onlyText = false, $bcc = false)
 {
     $hdrs = array('From' => $sender, 'Subject' => $subject, 'Date' => date("r"));
     if ($bcc) {
         //$hdrs['To'] = '';
     }
     $params = array("text_charset" => "UTF-8", "html_charset" => "UTF-8", "head_charset" => "UTF-8", "head_encoding" => "base64");
     $textparams = array('charset' => 'utf-8', 'content_type' => 'text/plain', 'encoding' => 'base64');
     $calendarparams = array('charset' => 'utf-8', 'content_type' => 'text/calendar;method=REQUEST', 'encoding' => 'base64');
     $email = new Mail_mimePart('', array('content_type' => 'multipart/alternative'));
     $textmime = $email->addSubPart($textbody, $textparams);
     $htmlmime = $email->addSubPart($calendarbody, $calendarparams);
     $final = $email->encode();
     $final['headers'] = array_merge($final['headers'], $hdrs);
     $smtp = Mail::factory('smtp', array('auth' => $GLOBALS['configuration']['smtp_auth'] ? true : false, 'host' => $GLOBALS['configuration']['smtp_host'], 'password' => $GLOBALS['configuration']['smtp_pass'], 'port' => $GLOBALS['configuration']['smtp_port'], 'username' => $GLOBALS['configuration']['smtp_user'], 'timeout' => $GLOBALS['configuration']['smtp_timeout'], 'localhost' => $_SERVER["HTTP_HOST"]));
     $result = $smtp->send($recipient, $final['headers'], $final['body']);
     return $result;
 }
开发者ID:kaseya-university,项目名称:efront,代码行数:18,代码来源:module_outlook_invitation.class.php

示例8: array

 function &_makeMimeMessage(&$xml, $encoding = SOAP_DEFAULT_ENCODING)
 {
     global $SOAP_options;
     if (!isset($SOAP_options['Mime'])) {
         return $this->_raiseSoapFault('Mime is not installed');
     }
     // encode any attachments
     // see http://www.w3.org/TR/SOAP-attachments
     // now we have to mime encode the message
     $params = array('content_type' => 'multipart/related; type=text/xml');
     $msg = new Mail_mimePart('', $params);
     // add the xml part
     $params['content_type'] = 'text/xml';
     $params['charset'] = $encoding;
     $params['encoding'] = 'base64';
     $msg->addSubPart($xml, $params);
     // add the attachements
     $c = count($this->__attachments);
     for ($i = 0; $i < $c; $i++) {
         $attachment =& $this->__attachments[$i];
         $msg->addSubPart($attachment['body'], $attachment);
     }
     return $msg->encode();
 }
开发者ID:nidhhoggr,项目名称:mycoachingoffice,代码行数:24,代码来源:Base.php

示例9: getHTTPBody

 /**
  * gets the HTTP body for the current response.
  *
  * @param string $soapmsg The SOAP payload
  * @return string The HTTP body, which includes the SOAP payload
  * @access private
  */
 function getHTTPBody($soapmsg)
 {
     if (count($this->responseAttachments) > 0) {
         $params['content_type'] = 'multipart/related; type="text/xml"';
         $mimeMessage = new Mail_mimePart('', $params);
         unset($params);
         $params['content_type'] = 'text/xml';
         $params['encoding'] = '8bit';
         $params['charset'] = $this->soap_defencoding;
         $mimeMessage->addSubpart($soapmsg, $params);
         foreach ($this->responseAttachments as $att) {
             unset($params);
             $params['content_type'] = $att['contenttype'];
             $params['encoding'] = 'base64';
             $params['disposition'] = 'attachment';
             $params['dfilename'] = $att['filename'];
             $params['cid'] = $att['cid'];
             if ($att['data'] == '' && $att['filename'] != '') {
                 if ($fd = fopen($att['filename'], 'rb')) {
                     $data = fread($fd, filesize($att['filename']));
                     fclose($fd);
                 } else {
                     $data = '';
                 }
                 $mimeMessage->addSubpart($data, $params);
             } else {
                 $mimeMessage->addSubpart($att['data'], $params);
             }
         }
         $output = $mimeMessage->encode();
         $mimeHeaders = $output['headers'];
         foreach ($mimeHeaders as $k => $v) {
             $this->debug("MIME header {$k}: {$v}");
             if (strtolower($k) == 'content-type') {
                 // PHP header() seems to strip leading whitespace starting
                 // the second line, so force everything to one line
                 $this->mimeContentType = str_replace("\r\n", " ", $v);
             }
         }
         return $output['body'];
     }
     return parent::getHTTPBody($soapmsg);
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:50,代码来源:nusoapmime.php

示例10: encode

 /**
  * Encode contexts
  *
  * @return none
  */
 public function encode()
 {
     $mimeType = Resources::MULTIPART_MIXED_TYPE;
     $batchGuid = Utilities::getGuid();
     $batchId = sprintf('batch_%s', $batchGuid);
     $contentType1 = array('content_type' => "{$mimeType}");
     $changeSetGuid = Utilities::getGuid();
     $changeSetId = sprintf('changeset_%s', $changeSetGuid);
     $contentType2 = array('content_type' => "{$mimeType}; boundary={$changeSetId}");
     $options = array('encoding' => 'binary', 'content_type' => Resources::HTTP_TYPE);
     // Create changeset MIME part
     $changeSet = new \Mail_mimePart();
     $i = 1;
     foreach ($this->_contexts as $context) {
         $context->addHeader(Resources::CONTENT_ID, $i);
         $changeSet->addSubpart((string) $context, $options);
         $i++;
     }
     // Encode the changeset MIME part
     $changeSetEncoded = $changeSet->encode($changeSetId);
     // Create the batch MIME part
     $batch = new \Mail_mimePart(Resources::EMPTY_STRING, $contentType1);
     // Add changeset encoded to batch MIME part
     $batch->addSubpart($changeSetEncoded['body'], $contentType2);
     // Encode batch MIME part
     $batchEncoded = $batch->encode($batchId);
     $this->_headers = $batchEncoded['headers'];
     $this->_body = $batchEncoded['body'];
 }
开发者ID:skinnard,项目名称:FTL-2,代码行数:34,代码来源:BatchRequest.php

示例11: printf

    printf("NO UID\n");
}
$new_attendees = array();
$props = $ical->GetPropertiesByPath('VEVENT/ATTENDEE');
for ($i = 0; $i < count($props); $i++) {
    printf("Attendee Mailto '%s' Status '%s'\n", str_ireplace("MAILTO:", "", $props[$i]->Value()), $props[$i]->Parameters()["PARTSTAT"]);
}
$ical->SetCPParameterValue("VEVENT", "ATTENDEE", "RSVP", null);
// MODIFICATIONS
// METHOD
$ical->SetPValue("METHOD", "REPLY");
//ATTENDEE
$ical->SetCPParameterValue("VEVENT", "ATTENDEE", "PARTSTAT", "ACCEPTED");
$ical->SetCPParameterValue("VEVENT", "ATTENDEE", "PARTSTAT", "TENTATIVE", "MAILTO:user2@zpush.org");
printf("%s\n", $ical->Render());
$mail = new Mail_mimePart();
$headers = array("MIME-version" => "1.0", "From" => $mail->encodeHeader("from", "Pedro Picapiedra <pedro.picapiedra@zpush.org>", "UTF-8"), "To" => $mail->encodeHeader("to", "Pablo Marmol <pablo.marmol@zpush.org>", "UTF-8"), "Date" => gmdate("D, d M Y H:i:s", time()) . " GMT", "Subject" => $mail->encodeHeader("subject", "This is a subject", "UTF-8"), "Content-class" => "urn:content-classes:calendarmessage", "Content-transfer-encoding" => "8BIT");
$mail = new Mail_mimePart($ical->Render(), array("content_type" => "text/calendar; method=REPLY; charset=UTF-8", "headers" => $headers));
$message = "";
$encoded_mail = $mail->encode();
foreach ($encoded_mail["headers"] as $k => $v) {
    $message .= $k . ": " . $v . "\r\n";
}
$message .= "\r\n" . $encoded_mail["body"] . "\r\n";
printf("%s\n", $message);
$props = $ical->GetPropertiesByPath("VTIMEZONE/TZID");
if (count($props) > 0) {
    $tzid = $props[0]->Value();
    printf("TZID %s\n", $props[0]->Value());
}
print_r(TimezoneUtil::GetFullTZFromTZName($tzid));
开发者ID:SvKn,项目名称:Z-Push-contrib,代码行数:31,代码来源:testing-imap_meeting.php


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