0

右の紳士、私は今まで一日中この文学にいました、私は必死です!これが状況です。無料の Web ホスティングを使用していますが、imap_open を使用しようとすると、次のメッセージが表示されます: 致命的なエラー: 未定義関数 imap_open() への呼び出し。私は明らかにサーバー設定にアクセスできず、プロバイダー (web000) に直接質問して imap 関数をサポートしているにもかかわらず、php に imap モジュールがインストールされていないように見えます。彼はそう答えた。私は彼にエラーメッセージをメールで送り、どうしてこれが可能かを尋ねました. 彼からまだ連絡がありません。とにかく、imap 関数が未定義であると仮定して、Gmail コンテンツにアクセスできる方法はありますか?この機能を取得するためにダウンロードできるライブラリはありますか? お時間をいただきありがとうございます。

4

1 に答える 1

3

Zend_Mailは IMAP プロトコルの純粋な php 実装 (メール サーバーへの接続にソケットを使用) であるため、imap 拡張子を必要とせずに imap メールボックスを読み取るためにZend_Mailを使用できます。

ホストで Zend Framework を使用するための特別な要件はありません。パッケージをダウンロードして解凍し、ホスティングにアップロードするだけです。次のコードを実行するのに問題ない最小限のエディションをお勧めします。

Gmail アカウントに接続するには、このコードで開始できます。アカウントに接続し、サーバーに保存されている最初のメッセージを取得して件名を出力し、それを展開できます。

<?
// Ensure Zend folder is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    '/home/tachyon/public_html/zend/library/',
     get_include_path(),
)));

// require the ZF autoloader file if you have it in your include path
require_once 'Zend/Loader/Autoloader.php';
// if ZF is not in your path you can specify the full path
// otherwise if it's in a subdir (most likely if you're on a web hosting)
// you can do something like this
//require_once dirname(__FILE__) . '/Zend/Loader/AutoLoader.php';

// laod the autoloader so you don't need to require any ZF file
Zend_Loader_Autoloader::getInstance();

// connecting with Imap to gmail
$mail = new Zend_Mail_Storage_Imap(
    array(
        'host'     => 'imap.gmail.com',
        'port'     => '993',
        'ssl'      => true,
        'user'     => 'user@gmail.com',
        'password' => 'secret',
    )
);

// get the message object
$message = $mail->getMessage(1);
// output subject of message
echo $message->subject . "\n";
// dump message headers
Zend_Debug::dump($message->getHeaders());

私は自分の Gmail アカウントでこれを個人的にテストしたので、動作するコードです。

于 2011-07-26T22:15:49.430 に答える