| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* @package Content-management
|
|
|
5 |
* @author Lars Tiefland <tiefland@weban.de>
|
|
|
6 |
* @copyright 2009 Webagentur Niewerth
|
|
|
7 |
* @license propietary http://www.weban.de
|
|
|
8 |
* @version $Rev$
|
|
|
9 |
* @filesource
|
|
|
10 |
*
|
|
|
11 |
*/
|
|
|
12 |
|
|
|
13 |
/**
|
|
|
14 |
*
|
|
|
15 |
* @package Content-management
|
|
|
16 |
* @author Lars Tiefland <tiefland@weban.de>
|
|
|
17 |
* @copyright 2009 Webagentur Niewerth
|
|
|
18 |
*/
|
|
|
19 |
|
|
|
20 |
// SVN: $Id: functions.common.php 51 2009-10-07 09:43:24Z tiefland $
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* This example provides a basic demonstration of how Mail_IMAP can be used to
|
|
|
24 |
* view multipart messages. See {@link connect} for extended documentation on
|
|
|
25 |
* how to set the connection URI.
|
|
|
26 |
*
|
|
|
27 |
* This example is part of the message viewer. Here the headers are retrieved for
|
|
|
28 |
* a message part and the message part itself is displayed using an inline frame.
|
|
|
29 |
*
|
|
|
30 |
*
|
|
|
31 |
* @author Richard York <rich_y@php.net?>
|
|
|
32 |
* @copyright (c) Copyright 2004, Richard York, All Rights Reserved.
|
|
|
33 |
* @package Mail_IMAP
|
|
|
34 |
* @subpackage examples
|
|
|
35 |
*
|
|
|
36 |
*/
|
|
|
37 |
|
|
|
38 |
// Use an existing imap resource stream, or provide a URI abstraction.
|
|
|
39 |
// Example of URI:
|
|
|
40 |
// pop3://user:pass@mail.example.com:110/INBOX#notls
|
|
|
41 |
//
|
|
|
42 |
// If you are unsure of the URI syntax to use here,
|
|
|
43 |
// use the Mail_IMAP_connection_wizard to find the right URI.
|
|
|
44 |
// Or see docs for Mail_IMAP::connect
|
|
|
45 |
//
|
|
|
46 |
// The connection URI must also be set in:
|
|
|
47 |
// IMAP.inbox.php.
|
|
|
48 |
// IMAP.message_viewer.php
|
|
|
49 |
// IMAP.part_viewer.php
|
|
|
50 |
|
|
|
51 |
require_once 'Mail/IMAP.php';
|
|
|
52 |
|
|
|
53 |
$connection = 'imap://rs:EW-ad-1055@mail.mediaran.de:143/INBOX';
|
|
|
54 |
|
|
|
55 |
if ( !isset($_GET['dump_mid']) )
|
|
|
56 |
{
|
|
|
57 |
$msg = &new Mail_IMAP();
|
|
|
58 |
}
|
|
|
59 |
else
|
|
|
60 |
{
|
|
|
61 |
// Call on debuging automatically.
|
|
|
62 |
include 'Mail/IMAP/Debug/Debug.php';
|
|
|
63 |
$msg = &new Mail_IMAP_Debug( $connection );
|
|
|
64 |
if ( $msg->error->hasErrors() )
|
|
|
65 |
{
|
|
|
66 |
$msg->dump( $msg->error->getErrors(true) );
|
|
|
67 |
}
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
// Open up a mail connection
|
|
|
71 |
if ( !$msg->connect($connection) )
|
|
|
72 |
{
|
|
|
73 |
echo $msg->alerts();
|
|
|
74 |
echo $msg->errors();
|
|
|
75 |
echo
|
|
|
76 |
'<SPAN style="font-weight: bold;">Error:</SPAN> Unable to build a connection.';
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
// Get parts and headers
|
|
|
80 |
$mid = $_GET['mid'];
|
|
|
81 |
$pid = $_GET['pid'];
|
|
|
82 |
|
|
|
83 |
$msg->getParts( $mid, $pid );
|
|
|
84 |
$msg->getHeaders( $mid, $pid );
|
|
|
85 |
|
|
|
86 |
function Mail_IMAP_do_address_line( &$msg, &$mid, $line )
|
|
|
87 |
{
|
|
|
88 |
$rtn = ( string )'';
|
|
|
89 |
|
|
|
90 |
if ( !empty($msg->header[$mid][$line]) )
|
|
|
91 |
{
|
|
|
92 |
foreach ( $msg->header[$mid][$line] as $i => $address )
|
|
|
93 |
{
|
|
|
94 |
if ( isset($msg->header[$mid][$line . '_personal'][$i]) && !
|
|
|
95 |
empty($msg->header[$mid][$line . '_personal'][$i]) )
|
|
|
96 |
{
|
|
|
97 |
$rtn .= "<SPAN title='" . $msg->header[$mid][$line][$i] .
|
|
|
98 |
"'>" . $msg->header[$mid][$line . '_personal'][$i] .
|
|
|
99 |
"</SPAN> ;\n";
|
|
|
100 |
}
|
|
|
101 |
else
|
|
|
102 |
{
|
|
|
103 |
$rtn .= str_replace( '@', ' at ', $msg->header[$mid][$line][$i] ) .
|
|
|
104 |
"; \n";
|
|
|
105 |
}
|
|
|
106 |
}
|
|
|
107 |
}
|
|
|
108 |
return $rtn;
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
function Mail_IMAP_do_parts( &$msg, &$mid, $disp )
|
|
|
112 |
{
|
|
|
113 |
$rtn = ( string )'';
|
|
|
114 |
|
|
|
115 |
if ( isset($msg->msg[$mid][$disp]['pid']) && count($msg->msg[$mid][$disp]['pid']) >
|
|
|
116 |
|
|
|
117 |
{
|
|
|
118 |
foreach ( $msg->msg[$mid][$disp]['pid'] as $i => $inid )
|
|
|
119 |
{
|
|
|
120 |
$rtn .= "<A href=" . $_SERVER['PHP_SELF'] . "?mid='{$mid}&pid=" .
|
|
|
121 |
$msg->msg[$mid][$disp]['pid'][$i] . "' target='top'>" .
|
|
|
122 |
$msg->msg[$mid][$disp]['fname'][$i] . " " . $msg->msg[$mid][$disp]['ftype'][$i] .
|
|
|
123 |
" " . $msg->convertBytes( $msg->msg[$mid][$disp]['fsize'][$i] ) .
|
|
|
124 |
"</A><BR>\n";
|
|
|
125 |
}
|
|
|
126 |
}
|
|
|
127 |
return $rtn;
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
echo "
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
<TITLE> Mail_IMAP Inbox </TITLE>
|
|
|
134 |
<LINK rel='stylesheet' type='text/css' href='IMAP.css' media='all'>
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
<TABLE id='headerviewer'>
|
|
|
138 |
<TBODY><TR><TD class='header''> Subject: </TD><TD> " . $msg->header[$mid]['subject'] .
|
|
|
139 |
" </TD></TR><TR><TD class='header'> To: </TD><TD>" . "\n" .
|
|
|
140 |
Mail_IMAP_do_address_line( $msg, $mid, 'to' ) . "
|
|
|
141 |
</TD></TR><TR><TD class='header'> Cc: </TD><TD>\n" .
|
|
|
142 |
Mail_IMAP_do_address_line( $msg, $mid, 'cc' ) . "
|
|
|
143 |
</TD></TR><TR><TD class='header'> From: </TD><TD>\n" .
|
|
|
144 |
Mail_IMAP_do_address_line( $msg, $mid, 'from' ) . "
|
|
|
145 |
</TD></TR><TR><TD class='header'> Received: </TD><TD>" . date( 'D d M, Y h:i:s',
|
|
|
146 |
$msg->header[$mid]['udate'] ) .
|
|
|
147 |
"</TD></TR><TR><TD class='header''> Inline Parts: </TD><TD>" .
|
|
|
148 |
Mail_IMAP_do_parts( $msg, $mid, 'in' ) .
|
|
|
149 |
"</TD></TR><TR><TD class='header'> Attachments: </TD><TD>" .
|
|
|
150 |
Mail_IMAP_do_parts( $msg, $mid, 'at' ) . "</TD></TR></TBODY>
|
|
|
151 |
</TABLE>
|
|
|
152 |
<IFRAME src='IMAP.part_viewer.php?mid={$mid}&pid={$pid}' name='part' style='width: 100%; height: 400px;'></IFRAME>
|
|
|
153 |
|
|
|
154 |
";
|
|
|
155 |
?>
|