Php imap_身体断裂
我有一个脚本,可以将邮件从一个源IMAP服务器传输到目标IMAP服务器。 我已经使用eclipse作为IDE在xampp中本地编写了这个脚本。 本地的,很好用。但是没有日期。因为我的XAMPP-PHP版本太旧了 因此,我将脚本移动到运行PHP5.3.6-pl0-gentoo的服务器上 步骤1: 在开始时,脚本将把一个盒子的所有邮件缓存到文件系统文件缓存上的文件中 步骤2: IMAP连接Ressource更改为目标IMAP邮箱后,脚本将在所有缓存邮件上执行IMAP_追加,以将这些邮件写入目标IMAP邮箱 我重复一遍,这个脚本在本地机器上运行良好,没有内部日期! INTERNALDATE仅用于imap_追加。因此,第一步缓存与INTERNALDATE无关 我的问题是: 在缓存邮件时,它会在4**封邮件后中断。每次都是同一封邮件被打断。 而且每次在imap_主体上它都会中断,这封邮件并没有什么特别之处:带有附件1x 32MB 7z文件的普通html 在本地计算机上,此邮件是通过此脚本传输的 有关执行的一些信息: PHP的执行超时设置为3 小时脚本正在运行3分钟 在它破裂之前。 PHP的内存限制设置为1GB 计算机有2GB脚本正在使用 在它崩溃之前是63MB。 PHP的套接字超时设置为3 小时。 加载此特殊文件的标题 邮件在两个系统上都可以正常工作。 只有在装载时,车身才会断裂。 在我的分析中,它在调用_user _func_数组后直接中断 imap_体 下面是我的脚本: 一封邮件的邮件头的GetterPhp imap_身体断裂,php,email,imap,Php,Email,Imap,我有一个脚本,可以将邮件从一个源IMAP服务器传输到目标IMAP服务器。 我已经使用eclipse作为IDE在xampp中本地编写了这个脚本。 本地的,很好用。但是没有日期。因为我的XAMPP-PHP版本太旧了 因此,我将脚本移动到运行PHP5.3.6-pl0-gentoo的服务器上 步骤1: 在开始时,脚本将把一个盒子的所有邮件缓存到文件系统文件缓存上的文件中 步骤2: IMAP连接Ressource更改为目标IMAP邮箱后,脚本将在所有缓存邮件上执行IMAP_追加,以将这些邮件写入目标IMA
/**
* Getter of $_rawHeader
* @access public
* @return Content of $_rawHeader
*/
public function getRawHeader($update=false) {
if(!$this->_rawHeader || $update) {
$cachename = urlencode('imap_'.$this->getIMAP()->getInstanceName().$this->getIndex().'_rawheader');
if(!($this->_rawHeader = $this->Cache()->get($cachename)) || $update) {
$this->_rawHeader = $this->getIMAP()->fetchheader($this->getIndex());
$this->Cache()->set($cachename, $this->_rawHeader, 2592000);
SYSLOG::debug($this->_rawHeader);
}
}
return $this->_rawHeader;
}
/**
* Getter of $_rawBody
* @access public
* @return Content of $_rawBody
*/
public function getRawBody($update=false) {
if(!$this->_rawBody || $update) {
$cachename = urlencode('imap_'.$this->getIMAP()->getInstanceName().$this->getIndex().'_rawbody');
if(!($this->_rawBody = $this->Cache()->get($cachename)) || $update) {
SYSLOG::debug($this->getIMAP()->body($this->getIndex()));
$this->_rawBody = $this->getIMAP()->body($this->getIndex());
SYSLOG::debug($this->_rawBody);
$this->Cache()->set($cachename, $this->_rawBody, 2592000);
}
}
return $this->_rawBody;
}
一封邮件的原始正文的获取者
/**
* Getter of $_rawHeader
* @access public
* @return Content of $_rawHeader
*/
public function getRawHeader($update=false) {
if(!$this->_rawHeader || $update) {
$cachename = urlencode('imap_'.$this->getIMAP()->getInstanceName().$this->getIndex().'_rawheader');
if(!($this->_rawHeader = $this->Cache()->get($cachename)) || $update) {
$this->_rawHeader = $this->getIMAP()->fetchheader($this->getIndex());
$this->Cache()->set($cachename, $this->_rawHeader, 2592000);
SYSLOG::debug($this->_rawHeader);
}
}
return $this->_rawHeader;
}
/**
* Getter of $_rawBody
* @access public
* @return Content of $_rawBody
*/
public function getRawBody($update=false) {
if(!$this->_rawBody || $update) {
$cachename = urlencode('imap_'.$this->getIMAP()->getInstanceName().$this->getIndex().'_rawbody');
if(!($this->_rawBody = $this->Cache()->get($cachename)) || $update) {
SYSLOG::debug($this->getIMAP()->body($this->getIndex()));
$this->_rawBody = $this->getIMAP()->body($this->getIndex());
SYSLOG::debug($this->_rawBody);
$this->Cache()->set($cachename, $this->_rawBody, 2592000);
}
}
return $this->_rawBody;
}
在IMAP类上调用函数:
/**
* Catch not accessable Method-Calls
*
* @param String Methodname
* @param String Arguments
*
* This Method is for calling IMAP-Functions without "imap_" präfix
* Possilbe Methods are: Look at http://de3.php.net/manual/en/ref.imap.php
*
* @link http://de3.php.net/manual/en/ref.imap.php
*
* @return null || Function-Return
*/
public function __call($function, $arguments) {
//SYSLOG::debug('Call Function "imap_'.$function.'" on IMAP-Connection: '.$this->getAddress().':'.$this->getUsername());
if(function_exists('imap_'.$function)) {
//Filtered Function that doesn't need Handle
$filter = array(
'8bit',
'alerts',
'base64',
'binary',
'errors',
'last_error',
'mail_compose',
'mime_header_decode',
'qprint',
'rfc822_parse_adrlist',
'rfc822_parse_headers',
'rfc822_write_address',
'timeout',
'utf7_decode',
'utf7_encode',
'utf8'
);
//SYSLOG::info($this->_handle);
if($function == 'reopen' && !$this->_handle) {
if(!$this->open()) {
return false;
}
}
//Make sure that the Connection is open if its needed
if(in_array($function, $filter) || $function == 'reopen' || $this->open()) {
if(!in_array($function, $filter)) {
// Prepend the imap resource to the arguments array
array_unshift($arguments, $this->_handle);
}
// Call the PHP function
$func = 'imap_'.$function;
//SYSLOG::debug($arguments);
SYSLOG::debug('Call Function "'.$func.'" on IMAP-Connection: '.$this->getAddress().':'.$this->getUsername());
$result = call_user_func_array($func, $arguments);
//SYSLOG::debug($result);
return $result;
} else {
SYSLOG::warning('IMAP-Connection not available! Call-Function: "imap_'.$function.'" aborted!');
}
} else {
SYSLOG::error('Call-Function: "imap_'.$function.'" does not exist!');
}
return null;
}
知道它为什么会坏吗
非常感谢您的帮助。我已经找到了解决问题的方法。 所以我发现邮件的附件太大了。我不知道它在我的xampp上是如何工作的,但它对我的生产系统来说绝对是太大了 这是一个解决办法。也许不是正确的解决方案。我不知道。但它是有效的 我已替换了:
$this->_rawBody = $this->getIMAP()->body($this->getIndex());
为此:
//Workaround for imap_body because Attachment is to big
$this->_rawBody = '';
$tmpFileName = 'data_'.$cachename.'.tmp';
$this->getIMAP()->savebody($tmpFileName, $this->getIndex());
$tmpFile = fopen($tmpFileName, 'r');
while(!feof($tmpFile)) {
$this->_rawBody .= fgets($tmpFile, 4096);
}
fclose($tmpFile);
unlink($tmpFileName);
谢谢大家考虑我的问题