Skip to content

Commit

Permalink
Bug fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Malte Goldenbaum committed Jan 20, 2017
1 parent 8c097f7 commit e45a196
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/IMAP/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ public function openFolder(Folder $folder)
}
}

public function createFolder($name){
return imap_createmailbox($this->connection, imap_utf7_encode($name));
}

/**
* Get messages from folder.
*
Expand All @@ -261,10 +265,12 @@ public function getMessages(Folder $folder, $criteria = 'ALL')
$availableMessages = imap_search($this->connection, $criteria, SE_UID);

if ($availableMessages !== false) {
$msglist = 1;
foreach ($availableMessages as $msgno) {
$message = new Message($msgno, $this);
$message = new Message($msgno, $msglist, $this);

$messages[$message->message_id] = $message;
$msglist++;
}
}
return $messages;
Expand Down
14 changes: 13 additions & 1 deletion src/IMAP/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Message {
* @var string
*/
public $uid = '';
public $msglist = 1;

/* HEADER */
public $subject = '';
Expand Down Expand Up @@ -69,9 +70,10 @@ class Message {
const ENC_OTHER = 5;


public function __construct($uid, Client $client)
public function __construct($uid, $msglist, Client $client)
{
$this->uid = $uid;
$this->msglist = $msglist;
$this->client = $client;

$this->parseHeader();
Expand Down Expand Up @@ -343,5 +345,15 @@ private function getEncoding($structure)
}
}
}
return null;
}

public function moveToFolder($mailbox = 'INBOX'){
$this->client->createFolder($mailbox);

if(imap_mail_move($this->client->connection, $this->msglist, $mailbox) == true){
return imap_expunge($this->client->connection);
}
return false;
}
}
2 changes: 1 addition & 1 deletion src/IMAP/Providers/LaravelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class LaravelServiceProvider extends ServiceProvider
public function boot()
{
$this->publishes([
__DIR__.'/../config/imap.php' => config_path('imap.php'),
__DIR__.'/../../config/imap.php' => config_path('imap.php'),
]);
}

Expand Down

0 comments on commit e45a196

Please sign in to comment.