final commit

This commit is contained in:
Sada Shiva
2016-02-04 13:42:21 +05:30
parent 11f4b086b7
commit 1c343ea3bf
169 changed files with 20476 additions and 192 deletions

View File

@@ -29,7 +29,7 @@ Just add following code in the head of your script:
use PhpImap\IncomingMail;
use PhpImap\IncomingMailAttachment;
### Usage example
### [Usage example](https://github.com/barbushin/php-imap/blob/master/example/index.php)
```php
$mailbox = new PhpImap\Mailbox('{imap.gmail.com:993/imap/ssl}INBOX', 'some@gmail.com', '*********', __DIR__);

View File

@@ -17,12 +17,11 @@
}
],
"require": {
"php": ">=5.3.0",
"ext-imap": "*"
"php": ">=5.3.0"
},
"autoload": {
"psr-4": {
"PhpImap\\": "src/PhpImap/"
"psr-0": {
"PhpImap": "src/"
}
},
"minimum-stability": "stable"

View File

@@ -62,5 +62,4 @@ class IncomingMailAttachment {
public $id;
public $name;
public $filePath;
public $disposition;
}

View File

@@ -170,7 +170,7 @@ class Mailbox {
*
* @return array Mails ids
*/
public function searchMailbox($criteria = 'UNSEEN') {
public function searchMailbox($criteria = 'ALL') {
$mailsIds = imap_search($this->getImapStream(), $criteria, SE_UID, $this->serverEncoding);
return $mailsIds ? $mailsIds : array();
}
@@ -337,17 +337,6 @@ class Mailbox {
return imap_mailboxmsginfo($this->getImapStream());
}
public function get_overview($mailId) {
$overview = imap_fetch_overview($this->getImapStream(), $mailId, FT_UID);
return $overview;
}
public function backup_getmail($mailId) {
$body = imap_body($this->getImapStream(), $mailId, 1.1);
return $body;
}
/**
* Gets mails ids sorted by some criteria
*
@@ -427,7 +416,6 @@ class Mailbox {
if(isset($head->to)) {
$toStrings = array();
// dd($mail);
foreach($head->to as $to) {
if(!empty($to->mailbox) && !empty($to->host)) {
$toEmail = strtolower($to->mailbox . '@' . $to->host);
@@ -451,6 +439,10 @@ class Mailbox {
}
}
if(isset($head->message_id)) {
$mail->messageId = $head->message_id;
}
$mailStructure = imap_fetchstructure($this->getImapStream(), $mailId, FT_UID);
if(empty($mailStructure->parts)) {
@@ -479,6 +471,7 @@ class Mailbox {
$data = imap_binary($data);
}
elseif($partStructure->encoding == 3) {
$data = preg_replace('~[^a-zA-Z0-9+=/]+~s', '', $data); // https://github.com/barbushin/php-imap/issues/88
$data = imap_base64($data);
}
elseif($partStructure->encoding == 4) {
@@ -528,7 +521,7 @@ class Mailbox {
'/(^_)|(_$)/' => '',
);
$fileSysName = preg_replace('~[\\\\/]~', '', $mail->id . '_' . $attachmentId . '_' . preg_replace(array_keys($replace), $replace, $fileName));
$attachment->filePath = $this->attachmentsDir .'../../../../../../public'. DIRECTORY_SEPARATOR . $fileSysName;
$attachment->filePath = $this->attachmentsDir . DIRECTORY_SEPARATOR . $fileSysName;
file_put_contents($attachment->filePath, $data);
}
$mail->addAttachment($attachment);