本文整理汇总了PHP中rcube_mime类的典型用法代码示例。如果您正苦于以下问题:PHP rcube_mime类的具体用法?PHP rcube_mime怎么用?PHP rcube_mime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了rcube_mime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send_itip_message
/**
* Send an iTip mail message
*
* @param array Event object to send
* @param string iTip method (REQUEST|REPLY|CANCEL)
* @param array Hash array with recipient data (name, email)
* @param string Mail subject
* @param string Mail body text label
* @param object Mail_mime object with message data
* @return boolean True on success, false on failure
*/
public function send_itip_message($event, $method, $recipient, $subject, $bodytext, $message = null)
{
if (!$this->sender['name']) {
$this->sender['name'] = $this->sender['email'];
}
if (!$message) {
$message = $this->compose_itip_message($event, $method);
}
$mailto = rcube_idn_to_ascii($recipient['email']);
$headers = $message->headers();
$headers['To'] = format_email_recipient($mailto, $recipient['name']);
$headers['Subject'] = $this->cal->gettext(array('name' => $subject, 'vars' => array('title' => $event['title'], 'name' => $this->sender['name'])));
// compose a list of all event attendees
$attendees_list = array();
foreach ((array) $event['attendees'] as $attendee) {
$attendees_list[] = $attendee['name'] && $attendee['email'] ? $attendee['name'] . ' <' . $attendee['email'] . '>' : ($attendee['name'] ? $attendee['name'] : $attendee['email']);
}
$mailbody = $this->cal->gettext(array('name' => $bodytext, 'vars' => array('title' => $event['title'], 'date' => $this->cal->lib->event_date_text($event, true), 'attendees' => join(', ', $attendees_list), 'sender' => $this->sender['name'], 'organizer' => $this->sender['name'])));
// append links for direct invitation replies
if ($method == 'REQUEST' && ($token = $this->store_invitation($event, $recipient['email']))) {
$mailbody .= "\n\n" . $this->cal->gettext(array('name' => 'invitationattendlinks', 'vars' => array('url' => $this->cal->get_url(array('action' => 'attend', 't' => $token)))));
} else {
if ($method == 'CANCEL') {
$this->cancel_itip_invitation($event);
}
}
$message->headers($headers, true);
$message->setTXTBody(rcube_mime::format_flowed($mailbody, 79));
// finally send the message
$this->itip_send = true;
$sent = $this->rc->deliver_message($message, $headers['X-Sender'], $mailto, $smtp_error);
$this->itip_send = false;
return $sent;
}
示例2: test_parse_message
/**
* Test parse_message()
*/
function test_parse_message()
{
$file = file_get_contents(__DIR__ . '/../src/html.msg');
$result = rcube_mime::parse_message($file);
$this->assertInstanceOf('rcube_message_part', $result);
$this->assertSame('multipart/alternative', $result->mimetype);
$this->assertSame('1.0', $result->headers['mime-version']);
$this->assertSame('=_68eeaf4ab95b5312965e45c33362338e', $result->ctype_parameters['boundary']);
$this->assertSame('1', $result->parts[0]->mime_id);
$this->assertSame(12, $result->parts[0]->size);
$this->assertSame('text/plain', $result->parts[0]->mimetype);
$this->assertSame("this is test", $result->parts[0]->body);
$this->assertSame('2', $result->parts[1]->mime_id);
$this->assertSame(0, $result->parts[1]->size);
$this->assertSame('multipart/related', $result->parts[1]->mimetype);
$this->assertCount(2, $result->parts[1]->parts);
$this->assertSame('2.1', $result->parts[1]->parts[0]->mime_id);
$this->assertSame(257, $result->parts[1]->parts[0]->size);
$this->assertSame('text/html', $result->parts[1]->parts[0]->mimetype);
$this->assertSame('UTF-8', $result->parts[1]->parts[0]->charset);
$this->assertRegExp('/<html>/', $result->parts[1]->parts[0]->body);
$this->assertSame('2.2', $result->parts[1]->parts[1]->mime_id);
$this->assertSame(793, $result->parts[1]->parts[1]->size);
$this->assertSame('image/jpeg', $result->parts[1]->parts[1]->mimetype);
$this->assertSame('base64', $result->parts[1]->parts[1]->encoding);
$this->assertSame('inline', $result->parts[1]->parts[1]->disposition);
$this->assertSame('photo-mini.jpg', $result->parts[1]->parts[1]->filename);
}
示例3: mh_find_match
function mh_find_match($message)
{
foreach ($this->prefs as $p) {
if (stristr(rcube_mime::decode_header($message->{$p}['header']), $p['input'])) {
return $p['color'];
}
}
return false;
}
示例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->assertEqual($item['out'], $res, "Header decoding for: " . $idx);
}
}
示例5: get
/**
* Returns header value
*/
public function get($name, $decode = true)
{
$name = strtolower($name);
if (isset($this->obj_headers[$name])) {
$value = $this->{$this->obj_headers[$name]};
} else {
$value = $this->others[$name];
}
return $decode ? rcube_mime::decode_header($value, $this->charset) : $value;
}
示例6: getRecipients
/**
* Get recipients' e-mail addresses
*
* @return array Recipients' addresses
*/
public function getRecipients()
{
// get sender address
$headers = $this->message->headers();
$to = rcube_mime::decode_address_list($headers['To'], null, false, null, true);
$cc = rcube_mime::decode_address_list($headers['Cc'], null, false, null, true);
$bcc = rcube_mime::decode_address_list($headers['Bcc'], null, false, null, true);
$recipients = array_unique(array_merge($to, $cc, $bcc));
$recipients = array_diff($recipients, array('undisclosed-recipients:'));
return $recipients;
}
示例7: check_mime_extensions
/**
* Check the correct configuration of the 'mime_types' mapping option
*/
function check_mime_extensions()
{
$types = array('application/zip' => 'zip', 'application/x-tar' => 'tar', 'application/java-archive' => 'jar', 'image/gif' => 'gif', 'image/svg+xml' => 'svg');
$errors = array();
foreach ($types as $mimetype => $expected) {
$ext = rcube_mime::get_mime_extensions($mimetype);
if ($ext[0] != $expected) {
$errors[] = array($mimetype, $ext, $expected);
}
}
return $errors;
}
示例8: decodeHeader
/**
* Given a header, this function will decode it according to RFC2047.
* Probably not *exactly* conformant, but it does pass all the given
* examples (in RFC2047).
*
* @param string $input Input header value to decode
*
* @return string Decoded header value
*/
protected function decodeHeader($input)
{
return rcube_mime::decode_mime_string($input, $this->params['default_charset']);
}
示例9: format_flowed
public static function format_flowed($text, $length = 72)
{
return rcube_mime::format_flowed($text, $length);
}
示例10: parse_headers
/**
* Extract mail headers for new filter form
*/
private function parse_headers($headers)
{
$result = array();
if ($headers->subject) {
$result[] = array('Subject', rcube_mime::decode_header($headers->subject));
}
// @TODO: List-Id, others?
foreach (array('From', 'To') as $h) {
$hl = strtolower($h);
if ($headers->{$hl}) {
$list = rcube_mime::decode_address_list($headers->{$hl});
foreach ($list as $item) {
if ($item['mailto']) {
$result[] = array($h, $item['mailto']);
}
}
}
}
return $result;
}
示例11: mail_import_itip
/**
* Handler for POST request to import an event attached to a mail message
*/
public function mail_import_itip()
{
$itip_sending = $this->rc->config->get('calendar_itip_send_option', $this->defaults['calendar_itip_send_option']);
$uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
$mime_id = rcube_utils::get_input_value('_part', rcube_utils::INPUT_POST);
$status = rcube_utils::get_input_value('_status', rcube_utils::INPUT_POST);
$delete = intval(rcube_utils::get_input_value('_del', rcube_utils::INPUT_POST));
$noreply = intval(rcube_utils::get_input_value('_noreply', rcube_utils::INPUT_POST));
$noreply = $noreply || $status == 'needs-action' || $itip_sending === 0;
$instance = rcube_utils::get_input_value('_instance', rcube_utils::INPUT_POST);
$savemode = rcube_utils::get_input_value('_savemode', rcube_utils::INPUT_POST);
$error_msg = $this->gettext('errorimportingevent');
$success = false;
$delegate = null;
if ($status == 'delegated') {
$delegates = rcube_mime::decode_address_list(rcube_utils::get_input_value('_to', rcube_utils::INPUT_POST, true), 1, false);
$delegate = reset($delegates);
if (empty($delegate) || empty($delegate['mailto'])) {
$this->rc->output->command('display_message', $this->gettext('libcalendaring.delegateinvalidaddress'), 'error');
return;
}
}
// successfully parsed events?
if ($event = $this->lib->mail_get_itip_object($mbox, $uid, $mime_id, 'event')) {
// forward iTip request to delegatee
if ($delegate) {
$rsvpme = intval(rcube_utils::get_input_value('_rsvp', rcube_utils::INPUT_POST));
$itip = $this->load_itip();
if ($itip->delegate_to($event, $delegate, $rsvpme ? true : false)) {
$this->rc->output->show_message('calendar.itipsendsuccess', 'confirmation');
} else {
$this->rc->output->command('display_message', $this->gettext('itipresponseerror'), 'error');
}
// the delegator is set to non-participant, thus save as non-blocking
$event['free_busy'] = 'free';
}
// find writeable calendar to store event
$cal_id = !empty($_REQUEST['_folder']) ? rcube_utils::get_input_value('_folder', rcube_utils::INPUT_POST) : null;
$dontsave = $_REQUEST['_folder'] === '' && $event['_method'] == 'REQUEST';
$calendars = $this->driver->list_calendars(calendar_driver::FILTER_PERSONAL);
$calendar = $calendars[$cal_id];
// select default calendar except user explicitly selected 'none'
if (!$calendar && !$dontsave) {
$calendar = $this->get_default_calendar($event['sensitivity']);
}
$metadata = array('uid' => $event['uid'], '_instance' => $event['_instance'], 'changed' => is_object($event['changed']) ? $event['changed']->format('U') : 0, 'sequence' => intval($event['sequence']), 'fallback' => strtoupper($status), 'method' => $event['_method'], 'task' => 'calendar');
// update my attendee status according to submitted method
if (!empty($status)) {
$organizer = null;
$emails = $this->get_user_emails();
foreach ($event['attendees'] as $i => $attendee) {
if ($attendee['role'] == 'ORGANIZER') {
$organizer = $attendee;
} else {
if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails)) {
$event['attendees'][$i]['status'] = strtoupper($status);
if (!in_array($event['attendees'][$i]['status'], array('NEEDS-ACTION', 'DELEGATED'))) {
$event['attendees'][$i]['rsvp'] = false;
}
// unset RSVP attribute
$metadata['attendee'] = $attendee['email'];
$metadata['rsvp'] = $attendee['role'] != 'NON-PARTICIPANT';
$reply_sender = $attendee['email'];
$event_attendee = $attendee;
}
}
}
// add attendee with this user's default identity if not listed
if (!$reply_sender) {
$sender_identity = $this->rc->user->list_emails(true);
$event['attendees'][] = array('name' => $sender_identity['name'], 'email' => $sender_identity['email'], 'role' => 'OPT-PARTICIPANT', 'status' => strtoupper($status));
$metadata['attendee'] = $sender_identity['email'];
}
}
// save to calendar
if ($calendar && $calendar['editable']) {
// check for existing event with the same UID
$existing = $this->driver->get_event($event, calendar_driver::FILTER_WRITEABLE | calendar_driver::FILTER_PERSONAL);
if ($existing) {
// forward savemode for correct updates of recurring events
$existing['_savemode'] = $savemode ?: $event['_savemode'];
// only update attendee status
if ($event['_method'] == 'REPLY') {
// try to identify the attendee using the email sender address
$existing_attendee = -1;
$existing_attendee_emails = array();
foreach ($existing['attendees'] as $i => $attendee) {
$existing_attendee_emails[] = $attendee['email'];
if ($event['_sender'] && ($attendee['email'] == $event['_sender'] || $attendee['email'] == $event['_sender_utf'])) {
$existing_attendee = $i;
}
}
$event_attendee = null;
$update_attendees = array();
foreach ($event['attendees'] as $attendee) {
if ($event['_sender'] && ($attendee['email'] == $event['_sender'] || $attendee['email'] == $event['_sender_utf'])) {
//.........这里部分代码省略.........
示例12: parse_body
/**
* Parse decrypted message body into structure
*
* @param string Message body
*
* @return array Message structure
*/
private function parse_body(&$body)
{
// Mail_mimeDecode need \r\n end-line, but gpg may return \n
$body = preg_replace('/\\r?\\n/', "\r\n", $body);
// parse the body into structure
$struct = rcube_mime::parse_message($body);
return $struct;
}
示例13: mail_headers
/**
* Get message headers for popup window
*/
function mail_headers($args)
{
$headers = $args['headers'];
$ret = array();
if ($headers->subject) {
$ret[] = array('Subject', rcube_mime::decode_header($headers->subject));
}
// @TODO: List-Id, others?
foreach (array('From', 'To') as $h) {
$hl = strtolower($h);
if ($headers->{$hl}) {
$list = rcube_mime::decode_address_list($headers->{$hl});
foreach ($list as $item) {
if ($item['mailto']) {
$ret[] = array($h, $item['mailto']);
}
}
}
}
if ($this->rc->action == 'preview') {
$this->rc->output->command('parent.set_env', array('sieve_headers' => $ret));
} else {
$this->rc->output->set_env('sieve_headers', $ret);
}
return $args;
}
示例14: check_mime_extensions
/**
* Check the correct configuration of the 'mime_types' mapping option
*/
public function check_mime_extensions()
{
$errors = array();
$types = array('application/zip' => 'zip', 'text/css' => 'css', 'application/pdf' => 'pdf', 'image/gif' => 'gif', 'image/svg+xml' => 'svg');
foreach ($types as $mimetype => $expected) {
$ext = rcube_mime::get_mime_extensions($mimetype);
if (!in_array($expected, (array) $ext)) {
$errors[] = array($mimetype, $ext, $expected);
}
}
return $errors;
}
示例15: rc_image_content_type
function rc_image_content_type($data)
{
return rcube_mime::image_content_type($data);
}