pear がなかったからpearからインストール
# yum install php-pear
# pear install NET_POP3
接続だけ書いてみてテスト
test.php
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<body>
<?php
ini_set('display_errors', 'On');
require_once('Net/POP3.php');
$pop3 = new Net_POP3();
$ret = $pop3->connect("ssl://pop.lolipop.jp", 995 );
if ( $ret === true ) {
print "OK\n";
}else {
print "NG\n";
exit;
}
念のためyahoo.co.jpとか、自分の会社のアドレスとかテストしてみてもダメっぽい
どうも、環境によって使えないとか...。PHP8系だとダメってことなのかな。
直接、POP3.phpを修正してしまう。
(*下記修正は、自己責任です。)
--- POP3.php_org 2023-01-31 10:57:01.710200202 +0900
+++ POP3.php 2023-01-30 17:15:29.303882260 +0900
@@ -51,9 +51,9 @@
* For usage see the example script
*/
-define('NET_POP3_STATE_DISCONNECTED', 1, true);
-define('NET_POP3_STATE_AUTHORISATION', 2, true);
-define('NET_POP3_STATE_TRANSACTION', 4, true);
+define('NET_POP3_STATE_DISCONNECTED', 1);
+define('NET_POP3_STATE_AUTHORISATION', 2);
+define('NET_POP3_STATE_TRANSACTION', 4);
class Net_POP3
{
@@ -141,6 +141,13 @@
var $_capability;
+ public function __construct() {
+ $this->_timestamp = ''; // Used for APOP
+ $this->_maildrop = array();
+ $this->_timeout = 3;
+ $this->_state = NET_POP3_STATE_DISCONNECTED;
+ $this->_socket = new Net_Socket();
+ }
/**
* Constructor. Sets up the object variables, and instantiates
@@ -149,11 +156,13 @@
*/
function Net_POP3()
{
+/*
$this->_timestamp = ''; // Used for APOP
$this->_maildrop = array();
$this->_timeout = 3;
$this->_state = NET_POP3_STATE_DISCONNECTED;
$this->_socket = new Net_Socket();
+*/
/*
* Include the Auth_SASL package. If the package is not available,
* we disable the authentication methods that depend upon it.
@@ -1214,4 +1223,4 @@
}
PHP8で、defineのtrueはいらなくなったらしい。
$thisの宣言の位置をコンストラクタにいれる。
とりあえず、通ったけど、Class "Auth_SASL" not foundでエラーがでる。
171行目の@include_once 'Auth/SASL.php';
が読み込まれていないみたいなので、constructに入れてみる。
再修正
144 public function __construct() {
145 $this->_timestamp = ''; // Used for APOP
146 $this->_maildrop = array();
147 $this->_timeout = 3;
148 $this->_state = NET_POP3_STATE_DISCONNECTED;
149 $this->_socket = new Net_Socket();
150 @include_once 'Auth/SASL.php';
151 }
分かりやすいように、POP3.phpのdebugをtrueにする
/**
* To allow class debuging
* @var boolean
*/
var $_debug = true;
Noticeが出たけど、
「+OK Logged in. C: STAT S:+OK 0 0」まで表示できたので、この修正POP3.phpを使ってみる。