Closed sedovserge closed 7 years ago
Add field
/**
* Callback custom body rules
* ```
* function customBodyRulesCallback( $result, $body, $structure, $debug )
* {
* return $result;
* }
* ```
* @var null|callable
*/
public $customBodyRulesCallback = null;
Insert expression
$result = (is_callable($this->customBodyRulesCallback)) ? call_user_func($this->customBodyRulesCallback, $result, $body, $structure, $this->debugBodyRule ) : $result;
In body of function public function processBounce($pos, $type, $totalFetched)
after call bmhBodyRules()
switch ($structure->type) {
case 0: // Content-type = text
$body = imap_fetchbody($this->mailboxLink, $pos, '1');
$result = bmhBodyRules($body, $structure, $this->debugBodyRule);
$result = (is_callable($this->customBodyRulesCallback)) ? call_user_func($this->customBodyRulesCallback, $result, $body, $structure, $this->debugBodyRule ) : $result;
break;
case 1: // Content-type = multipart
$body = imap_fetchbody($this->mailboxLink, $pos, '1');
// Detect encoding and decode - only base64
if ($structure->parts[0]->encoding == 4) {
$body = quoted_printable_decode($body);
} elseif ($structure->parts[0]->encoding == 3) {
$body = base64_decode($body);
}
$result = bmhBodyRules($body, $structure, $this->debugBodyRule);
$result = (is_callable($this->customBodyRulesCallback)) ? call_user_func($this->customBodyRulesCallback, $result, $body, $structure, $this->debugBodyRule ) : $result;
break;
case 2: // Content-type = message
$body = imap_body($this->mailboxLink, $pos);
if ($structure->encoding == 4) {
$body = quoted_printable_decode($body);
} elseif ($structure->encoding == 3) {
$body = base64_decode($body);
}
$body = substr($body, 0, 1000);
$result = bmhBodyRules($body, $structure, $this->debugBodyRule);
$result = (is_callable($this->customBodyRulesCallback)) ? call_user_func($this->customBodyRulesCallback, $result, $body, $structure, $this->debugBodyRule ) : $result;
break;
default: // unsupport Content-type
$this->output('Msg #' . $pos . ' is unsupported Content-Type:' . $structure->type, self::VERBOSE_REPORT);
return false;
}
And callback
public function customBodyRulesCallback( $result, $body, $structure, $debug ) {
//here custom rules
return $result;
}
NICE :) Tnx
thx for the code ;)
tag: 5.5.0
One more question, Is it possible to make support custom rules? Like a callback function? maybe callback in function:
I use composer, and I would like to work with standard rules and had the opportunity to add your own Tnx.