本文整理汇总了PHP中quoted_printable_encode函数的典型用法代码示例。如果您正苦于以下问题:PHP quoted_printable_encode函数的具体用法?PHP quoted_printable_encode怎么用?PHP quoted_printable_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quoted_printable_encode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: encodeString
/**
* Encode a given string to produce an encoded string.
*
* @param string $string
* @param int $firstLineOffset if first line needs to be shorter
* @param int $maxLineLength 0 indicates the default length for this encoding
*
* @return string
*
* @throws RuntimeException
*/
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
{
if ($this->charset !== 'utf-8') {
throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset));
}
return $this->_standardize(quoted_printable_encode($string));
}
示例2: _utf8mail
/**
* Send an email with the UTF-8 character set
* @param string $to
* @param string $subject
* @param string $body The HTML body part
* @param string $text The plaintext body part (optional)
* @return bool
*/
protected function _utf8mail($to, $subject, $body, $text = null)
{
$f3 = \Base::instance();
// Add basic headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'To: ' . $to . "\r\n";
$headers .= 'From: ' . $f3->get("mail.from") . "\r\n";
// Build multipart message if necessary
if ($text) {
// Generate message breaking hash
$hash = md5(date("r"));
$headers .= "Content-type: multipart/alternative; boundary=\"{$hash}\"\r\n";
// Normalize line endings
$body = str_replace("\r\n", "\n", $body);
$body = str_replace("\n", "\r\n", $body);
$text = str_replace("\r\n", "\n", $text);
$text = str_replace("\n", "\r\n", $text);
// Build final message
$msg = "--{$hash}\r\n";
$msg .= "Content-type: text/plain; charset=utf-8\r\n";
$msg .= "Content-Transfer-Encoding: quoted-printable\r\n";
$msg .= "\r\n" . quoted_printable_encode($text) . "\r\n";
$msg .= "--{$hash}\r\n";
$msg .= "Content-type: text/html; charset=utf-8\r\n";
$msg .= "Content-Transfer-Encoding: quoted-printable\r\n";
$msg .= "\r\n" . quoted_printable_encode($body) . "\r\n";
$msg .= "--{$hash}\r\n";
$body = $msg;
} else {
$headers .= "Content-type: text/html; charset=utf-8\r\n";
}
return mail($to, $subject, $body, $headers);
}
示例3: sendmail
public function sendmail($to, $from, $subject = "", $body = "", $mailtype, $cc = "", $bcc = "", $additional_headers = "")
{
$mail_from = $this->get_address($this->strip_comment($from));
$body = preg_replace("/(^|(\r\n))(\\.)/", ".", $body);
//$body = mb_encode_mimeheader($body, "utf-8", "B");
$body = quoted_printable_encode($body);
@($header .= "MIME-Version:1.0\r\n");
if ($mailtype == "HTML") {
$header .= "Content-Type:text/html; charset=utf-8\r\n";
//$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Transfer-Encoding: quoted-printable\r\n";
}
$header .= "To: " . $to . "\r\n";
if ($cc != "") {
$header .= "Cc: " . $cc . "\r\n";
}
//$header .= "From: $from<".$from.">\r\n";
$header .= "From: {$this->custom_from_name} <" . $this->custom_from_address . ">\r\n";
$header .= "Subject: " . "=?UTF-8?B?" . base64_encode($subject) . "?=" . "\r\n";
$header .= $additional_headers;
$header .= "Date: " . date("r") . "\r\n";
$header .= "X-Mailer:By Redhat (PHP/" . phpversion() . ")\r\n";
list($msec, $sec) = explode(" ", microtime());
$header .= "Message-ID: <" . date("YmdHis", $sec) . "." . $msec * 1000000 . "." . $mail_from . ">\r\n";
$TO = explode(",", $this->strip_comment($to));
if ($cc != "") {
$TO = array_merge($TO, explode(",", $this->strip_comment($cc)));
}
if ($bcc != "") {
$TO = array_merge($TO, explode(",", $this->strip_comment($bcc)));
}
$sent = TRUE;
$sent_address = array();
foreach ($TO as $rcpt_to) {
$rcpt_to = $this->get_address($rcpt_to);
$address_hash_sum = sha1($rcpt_to);
if (isset($sent_addresses[$address_hash_sum])) {
$this->log_write("Warning: Already sent to {$rcpt_to}\n");
continue;
}
if (!$this->smtp_sockopen($rcpt_to)) {
$this->log_write("Error: Cannot send email to " . $rcpt_to . "\n");
$sent = FALSE;
continue;
}
if ($this->smtp_send($this->host_name, $mail_from, $rcpt_to, $header, $body)) {
$this->log_write("E-mail has been sent to <" . $rcpt_to . ">\n");
$sent_addresses[$address_hash_sum] = 1;
} else {
$this->log_write("Error: Cannot send email to <" . $rcpt_to . ">\n");
$sent = TRUE;
//忽略离职
}
fclose($this->sock);
$this->log_write("Disconnected from remote host\n");
}
return $sent;
}
示例4: test_header_decode_qp
/**
* Test decoding of header values
* Uses rcube_mime::decode_mime_string()
*/
function test_header_decode_qp()
{
$test = array('quoted-printable (1)' => array('in' => '=?utf-8?Q?Certifica=C3=A7=C3=A3??=', 'out' => 'Certifica=C3=A7=C3=A3?'), 'quoted-printable (2)' => array('in' => '=?utf-8?Q?Certifica=?= =?utf-8?Q?C3=A7=C3=A3?=', 'out' => 'Certifica=C3=A7=C3=A3'), 'quoted-printable (3)' => array('in' => '=?utf-8?Q??= =?utf-8?Q??=', 'out' => ''), 'quoted-printable (4)' => array('in' => '=?utf-8?Q??= a =?utf-8?Q??=', 'out' => ' a '), 'quoted-printable (5)' => array('in' => '=?utf-8?Q?a?= =?utf-8?Q?b?=', 'out' => 'ab'), 'quoted-printable (6)' => array('in' => '=?utf-8?Q? ?= =?utf-8?Q?a?=', 'out' => ' a'), 'quoted-printable (7)' => array('in' => '=?utf-8?Q?___?= =?utf-8?Q?a?=', 'out' => ' a'));
foreach ($test as $idx => $item) {
$res = rcube_mime::decode_mime_string($item['in'], 'UTF-8');
$res = quoted_printable_encode($res);
$this->assertEquals($item['out'], $res, "Header decoding for: " . $idx);
}
}
示例5: it_decodes_a_quoted_printable_string_when_encoding_is_set
/**
* @test
*/
public function it_decodes_a_quoted_printable_string_when_encoding_is_set()
{
$decoder = new MessageDecoder();
// Let's use all Latin-1 chars.
$chars = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ';
$qp = quoted_printable_encode($chars);
$decoded = $decoder->decodeBody($qp, ENCQUOTEDPRINTABLE);
$this->assertEquals($chars, $decoded);
}
示例6: send
function send($mail)
{
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html;charset=utf-8\r\n";
$headers .= "Content-Transfer-Encoding: quoted-printable\r\n";
$headers .= "To: {$address}\r\n";
$headers .= 'From: =?UTF-8?B?' . base64_encode('贴吧签到助手') . "?=\r\n";
$message = quoted_printable_encode($message);
return mail($mail->address, '=?UTF-8?B?' . base64_encode($mail->subject) . '?=', $mail->message, $headers);
}
示例7: send_email
function send_email($to, $subject, $message, $from = '')
{
$headers = array();
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=UTF-8';
$headers[] = 'Content-Transfer-Encoding: quoted-printable';
$headers[] = "From: {$from}";
$email_message = quoted_printable_encode($message);
return mail($to, $subject, $email_message, implode("\n", $headers), '-f' . $from);
}
示例8: compileBody
/**
* @ignore
*/
public function compileBody()
{
$tString = "";
if ($this->transferEncoding === 'base64') {
$tString .= chunk_split(base64_encode($this->content));
} elseif ($this->transferEncoding === 'quoted-printable') {
$tString .= quoted_printable_encode($this->content);
} else {
$tString .= $this->content;
}
return $tString;
}
示例9: setTransformedBody
/**
* Takes a transformed body and turns it into the raw body string needed for the mime encoding.
*
* @param $transformedBody
*/
public final function setTransformedBody($transformedBody)
{
$encoding = isset($this->headers["Content-Transfer-Encoding"]) ? $this->headers["Content-Transfer-Encoding"] : "";
switch ($encoding) {
case "quoted-printable":
$this->setRawBody(quoted_printable_encode($transformedBody));
break;
case "base64":
$this->setRawBody(chunk_split(base64_encode($transformedBody), 76));
break;
default:
$this->setRawBody($transformedBody);
}
}
示例10: sendMail
private function sendMail($text)
{
if ($this->config['enable_mailer'] === true) {
$sender = $this->config['sender'];
$receiver = $this->config['receiver'];
$subject = $this->config['subject'];
$boundary = $this->mailer->generateBoundary();
$text = quoted_printable_encode($text);
$message = "\n--{$boundary}\n";
$message .= "Content-Type: text/plain; charset=UTF-8\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n\n";
$message .= "{$text}\n\n";
$message .= "--{$boundary}--\n";
$this->mailer->send($sender, $receiver, $subject, $message, $boundary);
}
}
示例11: sendmail
public function sendmail($to, $subject = "", $body = "", $mailtype, $cc = "", $bcc = "", $additional_headers = "")
{
$mail_from = $this->get_address($this->strip_comment($this->email));
$body = ereg_replace("(^|(\r\n))(\\.)", ".", $body);
$header .= "MIME-Version:1.0\r\n";
if ($mailtype == "HTML") {
$header .= "Content-Type:text/html;charset=" . $this->charset . "\r\n";
$header .= "Content-Transfer-Encoding: quoted-printable\r\n";
$body = quoted_printable_encode($body);
}
$header .= "To: " . $to . "\r\n";
if ($cc != "") {
$header .= "Cc: " . $cc . "\r\n";
}
$header .= "From: " . $this->getCharset($this->name) . " <" . $this->email . ">\r\n";
$header .= "Subject: " . $this->getCharset($subject) . "\r\n";
$header .= $additional_headers;
$header .= "Date: " . date("r") . "\r\n";
list($msec, $sec) = explode(" ", microtime());
$header .= "Message-ID: <" . date("YmdHis", $sec) . "." . $msec * 1000000 . "." . $this->email . ">\r\n";
$header .= "Return-Path: <" . $this->email . ">\r\n";
$TO = explode(",", $this->strip_comment($to));
if ($cc != "") {
$TO = array_merge($TO, explode(",", $this->strip_comment($cc)));
}
if ($bcc != "") {
$TO = array_merge($TO, explode(",", $this->strip_comment($bcc)));
}
$sent = TRUE;
foreach ($TO as $rcpt_to) {
$rcpt_to = $this->get_address($rcpt_to);
if (!$this->smtp_sockopen($rcpt_to)) {
$this->log_write("Error: Cannot send email to " . $rcpt_to . "\n");
$sent = FALSE;
continue;
}
if ($this->smtp_send($this->relay_host, $mail_from, $rcpt_to, $header, $body)) {
$this->log_write("E-mail has been sent to <" . $rcpt_to . ">\n");
} else {
$this->log_write("Error: Cannot send email to <" . $rcpt_to . ">\n");
$sent = FALSE;
}
fclose($this->sock);
$this->log_write("Disconnected from remote host\n");
}
return $sent;
}
示例12: gs_keyval_enc
function gs_keyval_enc($str)
{
/*
return str_replace(' ', '=20',
quoted_printable_encode($str, false));
*/
$str = quoted_printable_encode($str, false);
# encode trailing spaces:
do {
$str = preg_replace('/ ( *)$/', '=20$1', $str, -1, $cnt);
} while ($cnt > 0);
# encode leading spaces:
do {
$str = preg_replace('/^( *) /', '$1=20', $str, -1, $cnt);
} while ($cnt > 0);
return $str;
}
示例13: email_encode
function email_encode($String = '', $Caracteres = 'ISO-8859-1')
{
// Quoted-printed (Q)
if (function_exists('quoted_printable_encode')) {
$String = quoted_printable_encode($String);
$RT = '=?' . $Caracteres . '?Q?' . $String . '?=';
} else {
// IMAP 8bit (Q)
if (function_exists('imap_8bit')) {
$String = imap_8bit($String);
$RT = '=?' . $Caracteres . '?Q?' . $String . '?=';
} else {
$String = base64_encode($String);
$RT = '=?' . $Caracteres . '?B?' . $String . '?=';
}
}
return $RT;
}
示例14: parse
public static function parse($mimetype, $encoding, $body, $charset = "UTF-8")
{
$header = new RFC5322Header();
$header->setValue("Content-Type", $mimetype);
$header->get("Content-Type")->addExtra("charset", $charset);
$header->setValue("Content-Transfer-Encoding", $encoding);
switch ($encoding) {
case "7bit":
case "8bit":
case "binary":
// Keine weitere Kodierung gewuenscht!
break;
case "base64":
$body = chunk_split(base64_encode($body), 76, "\r\n");
break;
case "quoted-printable":
$body = quoted_printable_encode($body);
break;
}
return new RFC5322PlainBody($header, $body);
}
示例15: send
public function send()
{
$uid = md5(uniqid(time()));
$headers = [];
if ($this->from) {
$headers[] = 'From: ' . $this->from;
}
if ($this->replyTo) {
$headers[] = 'Reply-To: ' . $this->replyTo;
}
$headers[] = 'MIME-Version: 1.0';
$headers[] = "Content-Type: multipart/mixed; boundary=\"" . $uid . "\"";
$headers[] = "This is a multi-part message in MIME format.";
$headers[] = "--{$uid}";
$headers[] = "Content-type: text/html; charset=UTF-8";
$headers[] = "Content-Transfer-Encoding: quoted-printable";
$headers[] = '';
$headers[] = quoted_printable_encode($this->message);
$headers[] = '';
foreach ($this->attachments as $file) {
$name = basename($file);
$headers[] = "--{$uid}";
$headers[] = "Content-type: application/octet-stream; name=\"" . $name . "\"";
$headers[] = "Content-Transfer-Encoding: base64";
$headers[] = "Content-Disposition: attachment; filename=\"" . $name . "\"";
$headers[] = '';
$headers[] = chunk_split(base64_encode(file_get_contents($file)));
$headers[] = '';
}
$headers[] = "--{$uid}--";
$success = true;
foreach ($this->recipients as $to) {
$body = implode("\r\n", $headers);
$success = mail($to, $this->subject, '', $body);
Event::trigger('core.email.send', $to, $this->from, $this->subject, $body, $success);
$success = $success && $success;
}
return $success;
}