Skip to content

Commit 89cd9c7

Browse files
committed
Date handling in Folder::appendMessage() fixed #224
1 parent c887d63 commit 89cd9c7

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
77
## [UNRELEASED]
88
### Fixed
99
- NaN
10+
- Date handling in Folder::appendMessage() fixed #224
1011

1112
### Added
1213
- NaN
1314

1415
### Affected Classes
1516
- NaN
17+
- [Folder::class](src/IMAP/Folder.php)
1618

1719
### Breaking changes
1820
- NaN

src/IMAP/Folder.php

100644100755
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace Webklex\IMAP;
1414

15+
use Carbon\Carbon;
1516
use Webklex\IMAP\Exceptions\GetMessagesFailedException;
1617
use Webklex\IMAP\Exceptions\MessageSearchValidationException;
1718
use Webklex\IMAP\Query\WhereQuery;
@@ -425,7 +426,20 @@ public function getStatus($options) {
425426
* @throws Exceptions\ConnectionFailedException
426427
*/
427428
public function appendMessage($message, $options = null, $internal_date = null) {
428-
return imap_append($this->client->getConnection(), $this->path, $message, $options, $internal_date);
429+
/**
430+
* Check if $internal_date is parsed. If it is null it should not be set. Otherwise the message can't be stored.
431+
* If this parameter is set, it will set the INTERNALDATE on the appended message. The parameter should be a
432+
* date string that conforms to the rfc2060 specifications for a date_time value or be a Carbon object.
433+
*/
434+
435+
if ($internal_date != null) {
436+
if ($internal_date instanceof \Carbon\Carbon){
437+
$internal_date = $internal_date->format('d-M-Y H:i:s O');
438+
}
439+
return imap_append($this->client->getConnection(), $this->path, $message, $options, $internal_date);
440+
}
441+
442+
return imap_append($this->client->getConnection(), $this->path, $message, $options);
429443
}
430444

431445
/**

0 commit comments

Comments
 (0)