Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
cc17467f3b
@ -1544,7 +1544,8 @@ class EmailCollector extends CommonObject
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Scan IMAP inbox
|
// Scan IMAP inbox
|
||||||
$arrayofemail = imap_search($connection, $search, null, $charset);
|
$arrayofemail = imap_search($connection, $search, SE_UID, $charset);
|
||||||
|
|
||||||
if ($arrayofemail === false) {
|
if ($arrayofemail === false) {
|
||||||
// Nothing found or search string not understood
|
// Nothing found or search string not understood
|
||||||
$mapoferrrors = imap_errors();
|
$mapoferrrors = imap_errors();
|
||||||
@ -1556,6 +1557,8 @@ class EmailCollector extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$arrayofemailtodelete = array(); // Track email to delete to make the deletion at end.
|
||||||
|
|
||||||
// Loop on each email found
|
// Loop on each email found
|
||||||
if (!$error && !empty($arrayofemail) && count($arrayofemail) > 0) {
|
if (!$error && !empty($arrayofemail) && count($arrayofemail) > 0) {
|
||||||
// Loop to get part html and plain
|
// Loop to get part html and plain
|
||||||
@ -1589,11 +1592,8 @@ class EmailCollector extends CommonObject
|
|||||||
$header = $imapemail->getHeader()->raw;
|
$header = $imapemail->getHeader()->raw;
|
||||||
$overview = $imapemail->getAttributes();
|
$overview = $imapemail->getAttributes();
|
||||||
} else {
|
} else {
|
||||||
$operationslog .= '<br>email = '.((string) $imapemail);
|
$header = imap_fetchheader($connection, $imapemail, FT_UID);
|
||||||
|
$overview = imap_fetch_overview($connection, $imapemail, FT_UID);
|
||||||
//$header = imap_headerinfo($connection, $imapemail);
|
|
||||||
$header = imap_fetchheader($connection, $imapemail, 0);
|
|
||||||
$overview = imap_fetch_overview($connection, $imapemail, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$header = preg_replace('/\r\n\s+/m', ' ', $header); // When a header line is on several lines, merge lines
|
$header = preg_replace('/\r\n\s+/m', ' ', $header); // When a header line is on several lines, merge lines
|
||||||
@ -1620,7 +1620,7 @@ class EmailCollector extends CommonObject
|
|||||||
|
|
||||||
$emailto = $this->decodeSMTPSubject($overview[0]->to);
|
$emailto = $this->decodeSMTPSubject($overview[0]->to);
|
||||||
|
|
||||||
$operationslog .= '<br>** Process email '.dol_escape_htmltag($iforemailloop)." - References: ".dol_escape_htmltag($headers['References'])." - Subject: ".dol_escape_htmltag($headers['Subject']);
|
$operationslog .= '<br>** Process email #'.dol_escape_htmltag($iforemailloop)." - ".dol_escape_htmltag((string) $imapemail)." - References: ".dol_escape_htmltag($headers['References'])." - Subject: ".dol_escape_htmltag($headers['Subject']);
|
||||||
dol_syslog("** Process email ".$iforemailloop." References: ".$headers['References']." Subject: ".$headers['Subject']);
|
dol_syslog("** Process email ".$iforemailloop." References: ".$headers['References']." Subject: ".$headers['Subject']);
|
||||||
|
|
||||||
|
|
||||||
@ -1769,7 +1769,7 @@ class EmailCollector extends CommonObject
|
|||||||
|
|
||||||
// Parse IMAP email structure
|
// Parse IMAP email structure
|
||||||
/*
|
/*
|
||||||
$structure = imap_fetchstructure($connection, $imapemail, 0);
|
$structure = imap_fetchstructure($connection, $imapemail, FT_UID);
|
||||||
|
|
||||||
$partplain = $parthtml = -1;
|
$partplain = $parthtml = -1;
|
||||||
$encodingplain = $encodinghtml = '';
|
$encodingplain = $encodinghtml = '';
|
||||||
@ -1806,7 +1806,7 @@ class EmailCollector extends CommonObject
|
|||||||
//var_dump($parthtml);
|
//var_dump($parthtml);
|
||||||
//var_dump($partplain);
|
//var_dump($partplain);
|
||||||
|
|
||||||
$messagetext = imap_fetchbody($connection, $imapemail, ($parthtml != '-1' ? $parthtml : ($partplain != '-1' ? $partplain : 1)), FT_PEEK);
|
$messagetext = imap_fetchbody($connection, $imapemail, ($parthtml != '-1' ? $parthtml : ($partplain != '-1' ? $partplain : 1)), FT_PEEK|FTP_UID);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//var_dump($messagetext);
|
//var_dump($messagetext);
|
||||||
@ -3138,31 +3138,24 @@ class EmailCollector extends CommonObject
|
|||||||
|
|
||||||
// Error for email or not ?
|
// Error for email or not ?
|
||||||
if (!$errorforactions) {
|
if (!$errorforactions) {
|
||||||
if (!empty($targetdir) && empty($mode)) {
|
if (!empty($targetdir)) {
|
||||||
if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
|
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
|
||||||
dol_syslog("EmailCollector::doCollectOneCollector move message ".((string) $imapemail)." to ".$connectstringtarget, LOG_DEBUG);
|
|
||||||
$operationslog .= '<br>Move mail '.((string) $imapemail);
|
|
||||||
|
|
||||||
$res = imap_mail_move($connection, $imapemail, $targetdir, 0);
|
|
||||||
if ($res == false) {
|
|
||||||
$errorforemail++;
|
|
||||||
$this->error = imap_last_error();
|
|
||||||
$this->errors[] = $this->error;
|
|
||||||
|
|
||||||
$operationslog .= '<br>Error in move '.$this->error;
|
|
||||||
|
|
||||||
dol_syslog(imap_last_error());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Move mail using PHP-IMAP
|
// Move mail using PHP-IMAP
|
||||||
dol_syslog("EmailCollector::doCollectOneCollector move message ".($imapemail->getHeader()->get('subject'))." to ".$targetdir, LOG_DEBUG);
|
dol_syslog("EmailCollector::doCollectOneCollector move message ".($imapemail->getHeader()->get('subject'))." to ".$targetdir, LOG_DEBUG);
|
||||||
$imapemail->move($targetdir);
|
if (empty($mode)) {
|
||||||
|
$imapemail->move($targetdir);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_syslog("EmailCollector::doCollectOneCollector move message ".((string) $imapemail)." to ".$connectstringtarget, LOG_DEBUG);
|
||||||
|
$operationslog .= '<br>Move mail '.((string) $imapemail).' - '.$msgid;
|
||||||
|
|
||||||
|
$arrayofemailtodelete[$imapemail] = $msgid;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
|
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
|
||||||
dol_syslog("EmailCollector::doCollectOneCollector message ".((string) $imapemail)." to ".$connectstringtarget." was set to read", LOG_DEBUG);
|
|
||||||
} else {
|
|
||||||
dol_syslog("EmailCollector::doCollectOneCollector message '".($imapemail->getHeader()->get('subject'))."' using this->host=".$this->host.", this->access_type=".$this->acces_type." was set to read", LOG_DEBUG);
|
dol_syslog("EmailCollector::doCollectOneCollector message '".($imapemail->getHeader()->get('subject'))."' using this->host=".$this->host.", this->access_type=".$this->acces_type." was set to read", LOG_DEBUG);
|
||||||
|
} else {
|
||||||
|
dol_syslog("EmailCollector::doCollectOneCollector message ".((string) $imapemail)." to ".$connectstringtarget." was set to read", LOG_DEBUG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -3210,9 +3203,30 @@ class EmailCollector extends CommonObject
|
|||||||
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
|
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
|
||||||
$client->disconnect();
|
$client->disconnect();
|
||||||
} else {
|
} else {
|
||||||
|
foreach ($arrayofemailtodelete as $imapemail => $msgid) {
|
||||||
|
dol_syslog("EmailCollect::doCollectOneCollector delete email ".$imapemail." ".$msgid);
|
||||||
|
|
||||||
|
$operationslog .= "<br> delete email ".$imapemail." ".$msgid;
|
||||||
|
|
||||||
|
if (empty($mode) && empty($error)) {
|
||||||
|
$res = imap_mail_move($connection, $imapemail, $targetdir, CP_UID);
|
||||||
|
if ($res == false) {
|
||||||
|
$errorforemail++;
|
||||||
|
$this->error = imap_last_error();
|
||||||
|
$this->errors[] = $this->error;
|
||||||
|
|
||||||
|
$operationslog .= '<br>Error in move '.$this->error;
|
||||||
|
|
||||||
|
dol_syslog(imap_last_error());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($mode) && empty($error)) {
|
if (empty($mode) && empty($error)) {
|
||||||
dol_syslog("Expunge", LOG_DEBUG);
|
dol_syslog("Expunge", LOG_DEBUG);
|
||||||
imap_expunge($connection); // To validate any move
|
$operationslog .= "<br>Expunge";
|
||||||
|
|
||||||
|
imap_expunge($connection); // To validate all moves
|
||||||
}
|
}
|
||||||
imap_close($connection);
|
imap_close($connection);
|
||||||
}
|
}
|
||||||
@ -3253,7 +3267,7 @@ class EmailCollector extends CommonObject
|
|||||||
* getmsg
|
* getmsg
|
||||||
*
|
*
|
||||||
* @param Object $mbox Structure
|
* @param Object $mbox Structure
|
||||||
* @param string $mid prefix
|
* @param string $mid UID email
|
||||||
* @param string $destdir Target dir for attachments
|
* @param string $destdir Target dir for attachments
|
||||||
* @return array Array with number and object
|
* @return array Array with number and object
|
||||||
*/
|
*/
|
||||||
@ -3270,7 +3284,8 @@ class EmailCollector extends CommonObject
|
|||||||
// add code here to get date, from, to, cc, subject...
|
// add code here to get date, from, to, cc, subject...
|
||||||
|
|
||||||
// BODY
|
// BODY
|
||||||
$s = imap_fetchstructure($mbox, $mid);
|
$s = imap_fetchstructure($mbox, $mid, FT_UID);
|
||||||
|
|
||||||
|
|
||||||
if (!$s->parts) {
|
if (!$s->parts) {
|
||||||
// simple
|
// simple
|
||||||
@ -3316,8 +3331,8 @@ class EmailCollector extends CommonObject
|
|||||||
|
|
||||||
// DECODE DATA
|
// DECODE DATA
|
||||||
$data = ($partno) ?
|
$data = ($partno) ?
|
||||||
imap_fetchbody($mbox, $mid, $partno) : // multipart
|
imap_fetchbody($mbox, $mid, $partno, FT_UID) : // multipart
|
||||||
imap_body($mbox, $mid); // simple
|
imap_body($mbox, $mid, FT_UID); // simple
|
||||||
// Any part may be encoded, even plain text messages, so check everything.
|
// Any part may be encoded, even plain text messages, so check everything.
|
||||||
if ($p->encoding == 4) {
|
if ($p->encoding == 4) {
|
||||||
$data = quoted_printable_decode($data);
|
$data = quoted_printable_decode($data);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user