|
|
XLVI. IMAP,POP3,NNTP関数
以下の関数は、その名前から連想されるようにIMAP
プロトコルのみを扱うわけではありません。実装レベルのc-client
ライブラリは、NNTP、POP3、
ローカルなメールボックスのアクセスメソッドもサポートします。
この拡張モジュールは、c-clientライブラリがインストールされている
ことを要します。から最
新版を入手し、コンパイルして下さい。
いくつかのファイルをリンクパス(例:
/usr/local/lib/)およびインクルードディレクト
リ(例: /usr/local/include)にコピーする必要が
あります。コピーするべきファイルは、
make を実行した後に
imap-200x/c-lient の下のソースツリーにあります。
c-client.aを
/usr/local/lib/libc-client.a または
リンクパスの他のディレクトリにコピーして下さ
い。
注意:
c-client.a をリンクパスに
libc-client.aという名前でコピーして下さい。
以下のファイルを/usr/local/include または
インクルードパスの他のディレクトリにコピーし
て下さい。
c-client.h | imap4r1.h | rfc822.h | mail.h | linkage.h | env.h | env_unix.h | fs.h | ftl.h | misc.h | nntp.h | nl.h | osdep.h | smtp.h | tcp.h |
注意:
env_unix.hの名前は、使用するOSに依存します。
以下のシンボリックオプションを指定してこのファイルをコピーするよ
うにして下さい。SSLまたはKerberosサポートを指定してc-clientライ
ブラリを構築するには、パッケージに付属するドキュメントを読んで下
さい。
以下の関数を動作させるには、--with-imap=[DIR]を指定してPHPをコンパイル
する必要があります。ただし、DIRはc-clientインストールプレフィックス
です。
注意:
c-clientの設定によっては、
--with-imap-ssl=/path/to/openssl/
または
--with-kerberos=/path/to/kerberos
をconfigureのオプションに指定する必要があります。
この拡張モジュールは設定ディレクティブを全く定義しません。
これらの定数は、この拡張モジュールで定義されており、
この拡張モジュールがPHP内部にコンパイルされているか実行時に動的にロー
ドされるかのどちらかの場合のみ使用可能です。
この文書では、提供される関数に関する全ての話題の詳細について立ち入
ることはできません。より詳細な情報については、Cクライアントライブ
ラリのソースに付属するドキュメント
(docs/internal.txt)および以下のRFCドキュメン
トで提供されています。
: Simple Mail
Transfer Protocol (SMTP).
: Standard for
ARPA internet text messages.
: Internet
Message Access Protocol (IMAP) Version 4rev1.
: Post
Office Protocol Version 3 (POP3).
: Network News
Transfer Protocol (NNTP).
: Common
Internet Message Headers.
, , , & : Multipurpose
Internet Mail Extensions (MIME).
詳しい概観については、David Woodによる本
や Dianna Mullet と Kevin Mullet によるでも得ることができます。
警告 |
recode拡張モジュールとともにこの拡張モジュールをロードした際に
PHP がクラッシュしたり、起動できないという問
題が発生する可能性があります。
詳細な情報については、recode
拡張モジュールを参照下さい。
|
add a note
User Contributed Notes
IMAP,POP3,NNTP関数
seem dot iges at mail dot ee
15-Feb-2005 01:48
If you like me disvoer that "make slx" fails, but you're damn sure you've openssl installed then, it might be that the lib and include paths on your distro are different then the defaults provided in the imap-2004a (or imap-XXXXx). To modify go to dir ../imap-2004a/src/osdep/unix and edit the section (shown below) in the Makefile
# Extended flags needed for SSL. You may need to modify.
#SSLDIR=/usr/local/ssl
SSLDIR=/etc/ssl
SSLCERTS=$(SSLDIR)/certs
SSLKEYS=$(SSLCERTS)
#SSLINCLUDE=$(SSLDIR)/include
SSLINCLUDE=/usr/include/openssl
#SSLLIB=$(SSLDIR)/lib
SSLLIB=/usr/lib
SSLCRYPTO=-lcrypto
Commented out SSLDIR, SSLINCLUDE and SSLIB are defaults and the uncommented are valid paths for Slackware (10.0/10.1).
You should also check your ld.so.conf for valid paths.
antivert
13-Jan-2005 04:55
Note that is not not necessary to disable SSL in the IMAP compile to make it work with PHP 5.0.3.
1. Compile IMAP with SSL support for your system:
cd /path/to/imap/source/
make <system type> (ldb, lnx, etc)
mkdir include
mkdir lib
2. Make links in IMAP source directory:
cd /path/to/imap/source/c-client
cp *.h ../include/
cp *.c ../lib/
cp c-client.a ../lib/libc-client.a
3. Compile PHP with SSL support, --with-imap=/path/to/imap/source/ . If SSL support fails, you'll get a configure-time error that IMAP doesn't work. This is a lie, you just need to get SSL support working in PHP. On certain linux systems, with OpenSSL 0.9.7, this means adding --with-openssl=/usr (if the OpenSSL files are in /usr/include/openssl/) instead of the proper directory containing the OpenSSL files. For some reason, giving a parent directory makes PHP able to find the OpenSSL include files.
4. PHP should build.
Alternately, you can disable SSL during the IMAP build, as per the previous directions posted here.
amit dot gupta at prudence-india dot com
18-Nov-2004 08:44
I faced problem in compiling imap with php-5.0.2 release version. Then following commands on snapshot version solved my problem
# tar -zxvf imap-2004b.DEV.tar.Z
# cd imap-2004b.DEV.SNAP-0411051435/
# make lnp SSLTYPE=none
# cp -r /usr/local/imap-2004b.DEV.SNAP-0411051435/c-client/*.h /usr/local/imap-2004b.DEV.SNAP-0411051435/include/
# cp -r /usr/local/imap-2004b.DEV.SNAP-0411051435/c-client/*.c /usr/local/imap-2004b.DEV.SNAP-0411051435/lib/
# ln -s /usr/local/imap-2004b.DEV.SNAP-0411051435/c-client/c-client.a /usr/local/imap-2004b.DEV.SNAP-0411051435/lib/libc-client.a
# tar -zxvf php5-STABLE-200411180530.tar.gz
# cd php5-STABLE-200411180530
./configure --with-apxs2=/usr/sbin/apxs --enable-shared --with-mod_charset --enable-force-cgi-redirect --enable-fastcgi --enable-magic-quotes --with-openssl --with-zlib --enable-bcmath --enable-calendar --with-curl --with-curlwrappers --enable-dba --with-gdbm --with-cdb --with-inifile --with-flatfile --enable-dbase --enable-dbx --enable-dio --with-fam --enable-filepro --enable-ftp --with-ldap --enable-mbstring --with-mysql=/usr/include --with-zlib-dir --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-pic --enable-versioning --with-pgsql --with-java=/usr/java/jdk1.5.0/ --with-imap=/usr/local/imap-2004b.DEV.SNAP-0411051435 --with-kerberos
# make
# make install
Thus, php compiled sucessufully with imap support on fedora core 1.
sirber at gmail dot com
17-Nov-2004 06:42
Here's a function to create a full structure with decoded bodies. Usefull for handeling complex MIME messages.
// Construction de la structure du message
$struct = imap_fetchstructure($mbox, $mnum);
// Recherche des body et d�codage de la structure
buildparts($mbox, $mnum, $struct);
function buildparts ($mbox, $mnum, &$struct, $pno = "")
{
switch ($struct->type)
{
case 1: // multipart
// Recherche des sous partie
$i = 1;
while (list($j) = each ($struct->parts))
buildparts ($mbox, $mnum, $struct->parts[$j], $pno . "." . $i++);
break;
case 2: // message
// D�codage de la sous partie (et de ses sous parties)
buildparts ($mbox, $mnum, $struct->parts[0], $pno);
break;
default:
$part = substr ($pno, 1);
// On save le part_number
$struct->part_number = $part;
// On fetch le body de la partie
$struct->body = imap_fetchbody($mbox, $mnum, $part);
// On le d�code
if($struct->encoding == 3)
$struct->body = imap_base64($struct->body);
elseif($struct->encoding == 4)
$struct->body = imap_qprint($struct->body);
// On d�code les charset
if ($struct->paraneters[0]->attribute == "CHARSET")
{
$charset = $struct->paraneters[0]->value;
if ($charset == "utf-8")
$struct->body = utf8_decode($struct->body);
if ($charset == "utf-7")
$struct->body = imap_utf7_decode($struct->body);
}
break;
}
}
Pete Spicer, sleeping [at] myperch.org
17-Jul-2004 10:19
I have a pretty much stock set-up of SuSE 8.1 Personal (Apache, PHP et al built by me) and IMAP-2004 refused to build for me.
What I found was, using the make lsu (for SuSE) almost worked built I was getting odd build results, i.e. make failures.
The problem? GCC 3.2. If you don't have an older GCC available, please install one! I installed the gcc_old package from SuSE and built with the following command:
CC=gcc297 make lsu SSLTYPE=none
The result was a perfect build. So if you are getting errors, please try an earlier build of GCC.
Tomas V.V.Cox
11-May-2004 01:15
For compiling this extension without compiling imap from sources I did (this was mandrake):
Install the following rpms:
imap
imap-devel
openssl
openssl-devel
krb5
krb5-devel
pam
pam-devel
Do the trick:
# mkdir /usr/include/imap/lib
# cp /usr/lib/libc-client-PHP4.a /usr/include/imap/lib/libc-client.a
And the configure line:
./configure <options> --with-imap=/usr/include/imap --with-imap-ssl
(don't forget --enable-pear ;)
sysadmin at grmtech dot com
27-Mar-2004 12:01
The manual mentions:
"From the c-client directory from your IMAP source tree, copy all the *.h files into include/ and all the *.c files into lib/. Additionally when you compiled IMAP, a file named c-client.a was created. Also put this in the lib/ directory but rename it as libc-client.a.
"
A. Please do not copy rather make symbolic links like this:
ln -s c-client include
ln -s c-client lib
B. You do not need to copy c-client.a to libc-client.a.
The make command used to compile the imap-2002e source code creates the symbolic link from c-client.a to libc-client.a
The imap client version used for the above two points is:
1. imap-2002e
my 2 cents,
sysadmin
peder at godvik dot no
09-Mar-2004 04:24
Additionally to Mauricio's procedure; You must check the Makefile to find the correct system type that you are compiling on. Mauricio's example assumes you are using Linux. -Check the README for imap-xxxx for further details.
Fjor
15-Feb-2004 01:50
Additionally to Mauricio's procedure, I had to make a symlink to the c-client library this way:
cd imap-xxxx/c-client
ln -s c-client.a libc-client.a
(Tested with imap-200e)
Fjor (GDL/Mexico)
dev at puertocity dot com
26-Nov-2003 04:38
A tip for imap support installation:
With SSL support:
------------------
tar -zxf imap-xxxxx.tar.Z
cd imap-xxxxx
make slx
ln -sf c-client include
ln -sf c-client lib
cd ..
tar -jxf php-4.3.x.tar.bz2
cd php-4.3.x
./configure --with-imap=../imap-xxxxx --with-imap-ssl=/path-to-openssl
With out SSL support:
---------------------
tar -zxf imap-xxxxx.tar.Z
cd imap-xxxxx
make slx SSLTYPE=none
ln -sf c-client include
ln -sf c-client lib
cd ..
tar -jxf php-4.3.x.tar.bz2
cd php-4.3.x
./configure --with-imap=../imap-xxxxx
Good Luck
Mauricio
millz at incogen dot com
10-Oct-2003 11:19
I experienced a problem when adding IMAP support into PHP. The php configure script would die when trying to see if "IMAP Works..." and the config.log would complain about libc-client.a references.
It was similar to the problem reported here:
I resolved it by compiling IMAP like this (replace <ARCH> with the proper OS type for your system, get that from the top of the Makefile):
make <ARCH> SSLTYPE=none
That turned off the SSL support in the IMAP files and seemed to resolve my php compile problem.
BTW, I also followed the directions about making a new /usr/local/imap... directory that are mentioned at the top of the page.
k3nny at squidart dot co dot za
01-Aug-2003 12:02
After having numerous problems compiling PHP with IMAP support, both PHP problems and IMAP problems I found this simple solution to the problem, which I've tried with several versions of IMAP and all worked perfectly!
tar -zxf imap-xxxxx.tar.Z
cd imap-xxxxx
make slx
ln -sf c-client include
ln -sf c-client lib
cd ..
tar -jxf php-4.3.x.tar.bz2
cd php-4.3.x
./configure --with-imap=../imap-xxxxx
It worked everytime for me, hope it does for you!
Kenneth
designer at bs-dee dot org
09-Mar-2003 12:27
The only c-client that has worked 100% with php is
DO NOT DOWNLOAD 2002 B its BUGGY!
keeper at odi dot com dot br
01-Mar-2003 08:37
For those working with mail talke a look ate the pear class
Mime decode:
Dotrinador
naveed at php dot net
12-Jan-2003 03:49
Beware!
If you are trying to make a connection with POP3 mailbox,then some of IMAP functions will not work correctly as you might expecting .This is because the difference of workings in POP3 and IMAP protocols.
These functions work correctly for IMAP mailboxes but some of the fnctions will return nothing, when connected to a POP3 mailbox.(even no error message).
duckel at electroporn dot de
22-May-2002 06:16
please don't copy the .h files in the system include directory! the unix.h file from the washington.edu c-client conflicts with another file called unix.h
make a dir called "imap" in either /usr/include or /usr/local/include or whatever you wish, copy the header files there and the .a file prefix'ish in /usr/lib or /usr/local/lib or whatever you used for the include files.
then tell configure with --with-imap=/usr the "prefix" of your installation.
then works without problem ;)
netshadow at madpoets dot org
03-Nov-2001 09:42
I just found something a bit bizarre. I was having problems with the pages taking too long to load (15-20sec) when they opened an imap connection. I was pulling my hair out trying to figure out what was wrong.
Turns out it was quite simple. I was letting it default to 143 for the port. When i specified the port number (i.e. {localhost:143} rather than {localhost} ) It reduced page load time to a few seconds.
raoul at runtheotherway dot com
22-Oct-2001 02:11
I have found the order in which you connect to you POP server with IMAP 2000 and your database with PostgreSQL 7.1.2 can cause problems.
Make sure that you connect first to your POP server then get your db connection. This will prevent you from getting an invalid stream from imap_open().
| |