Compare commits
No commits in common. "master" and "1.0.2" have entirely different histories.
56 changed files with 1188 additions and 3560 deletions
|
|
@ -1,23 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php">
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Project Test Suite">
|
||||
<directory>tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./src/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
15
.editorconfig
Normal file
15
.editorconfig
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
; This file is for unifying the coding style for different editors and IDEs.
|
||||
; More information at http://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -1,5 +1,5 @@
|
|||
/vendor
|
||||
.phpintel/
|
||||
coverage.clover
|
||||
.env
|
||||
.php_cs.cache
|
||||
build
|
||||
build/
|
||||
index.php
|
||||
39
.php_cs.dist
39
.php_cs.dist
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
$fileHeaderComment = <<<COMMENT
|
||||
This file is part of the Imap PHP package.
|
||||
(c) Clivern <hello@clivern.com>
|
||||
COMMENT;
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in(__DIR__)
|
||||
->exclude('var')
|
||||
;
|
||||
return PhpCsFixer\Config::create()
|
||||
->setIndent(" ")
|
||||
->setLineEnding("\n")
|
||||
->setRiskyAllowed(true)
|
||||
->setRules([
|
||||
'@PSR2' => true,
|
||||
'@Symfony' => true,
|
||||
'@Symfony:risky' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'header_comment' => ['header' => $fileHeaderComment, 'separate' => 'both'],
|
||||
'linebreak_after_opening_tag' => true,
|
||||
'mb_str_functions' => true,
|
||||
'no_php4_constructor' => true,
|
||||
'no_unreachable_default_argument_value' => true,
|
||||
'no_useless_else' => true,
|
||||
'no_useless_return' => true,
|
||||
'ordered_imports' => true,
|
||||
'php_unit_strict' => true,
|
||||
'phpdoc_order' => true,
|
||||
'semicolon_after_instruction' => true,
|
||||
'strict_comparison' => true,
|
||||
'strict_param' => true,
|
||||
'phpdoc_add_missing_param_annotation' => true,
|
||||
'ordered_class_elements'=> true,
|
||||
'phpdoc_types_order' => true,
|
||||
'logical_operators' => true,
|
||||
])
|
||||
->setFinder($finder)
|
||||
->setCacheFile(__DIR__.'/.php_cs.cache')
|
||||
;
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
language: php
|
||||
dist: precise
|
||||
|
||||
php:
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.2
|
||||
- 7.3
|
||||
- 7.4
|
||||
|
||||
## Cache composer
|
||||
cache:
|
||||
|
|
@ -18,4 +16,4 @@ before_script:
|
|||
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist
|
||||
|
||||
script:
|
||||
- make ci
|
||||
- vendor/bin/phpunit --bootstrap vendor/autoload.php --coverage-text --coverage-clover=coverage.clover
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at hello@clivern.com. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
## Contributing
|
||||
|
||||
- With issues:
|
||||
- Use the search tool before opening a new issue.
|
||||
- Please provide source code and commit sha if you found a bug.
|
||||
- Review existing issues and provide feedback or react to them.
|
||||
|
||||
- With pull requests:
|
||||
- Open your pull request against `master`
|
||||
- Your pull request should have no more than two commits, if not you should squash them.
|
||||
- It should pass all tests in the available continuous integrations systems such as TravisCI.
|
||||
- You should add/modify tests to cover your proposed code changes.
|
||||
- If your pull request contains a new feature, please document it on the README.
|
||||
2
LICENSE
2
LICENSE
|
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 Cliven
|
||||
Copyright (c) 2017 A. F
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
|||
57
Makefile
57
Makefile
|
|
@ -1,57 +0,0 @@
|
|||
COMPOSER ?= composer
|
||||
PHPUNIT_OPTS =
|
||||
|
||||
|
||||
composer:
|
||||
$(COMPOSER) install
|
||||
|
||||
|
||||
fix:
|
||||
./vendor/bin/php-cs-fixer fix
|
||||
|
||||
|
||||
fix-diff:
|
||||
./vendor/bin/php-cs-fixer fix --diff --dry-run -v
|
||||
|
||||
|
||||
test: composer
|
||||
vendor/bin/phpunit -c .
|
||||
|
||||
|
||||
lint: lint-php phpcs php-cs lint-composer lint-eol
|
||||
@echo All good.
|
||||
|
||||
|
||||
lint-eol:
|
||||
@echo "\n==> Validating unix style line endings of files:files"
|
||||
@! grep -lIUr --color '^M' src/ composer.json composer.lock || ( echo '[ERROR] Above files have CRLF line endings' && exit 1 )
|
||||
@echo All files have valid line endings
|
||||
|
||||
|
||||
lint-composer:
|
||||
@echo "\n==> Validating composer.json and composer.lock:"
|
||||
$(COMPOSER) validate --strict
|
||||
|
||||
|
||||
lint-php:
|
||||
@echo "\n==> Validating all php files:"
|
||||
@find src tests -type f -name \*.php | while read file; do php -l "$$file" || exit 1; done
|
||||
|
||||
|
||||
phpcs:
|
||||
vendor/bin/phpcs
|
||||
|
||||
|
||||
php-cs:
|
||||
vendor/bin/php-cs-fixer fix --diff --dry-run -v
|
||||
|
||||
|
||||
coverage: composer
|
||||
vendor/bin/phpunit -c .
|
||||
|
||||
|
||||
ci: composer lint test
|
||||
@echo "All quality checks passed"
|
||||
|
||||
|
||||
.PHONY: test composer coverage phpcs php-cs lint lint-php ci
|
||||
29
README.md
29
README.md
|
|
@ -2,7 +2,7 @@ Imap
|
|||
====
|
||||
:mailbox_with_mail: Access Mailbox Using PHP IMAP.
|
||||
|
||||
*Current Version: 1.0.6*
|
||||
*Current Version: 1.0.2*
|
||||
|
||||
[](https://travis-ci.org/Clivern/Imap)
|
||||
|
||||
|
|
@ -265,30 +265,9 @@ Misc
|
|||
|
||||
Changelog
|
||||
---------
|
||||
Version 1.0.6:
|
||||
```
|
||||
Fix Class Name.
|
||||
```
|
||||
|
||||
Version 1.0.5:
|
||||
```
|
||||
Enhance code style.
|
||||
Automate code fixes and linting.
|
||||
```
|
||||
|
||||
Version 1.0.4:
|
||||
```
|
||||
Fix for plain text messages.
|
||||
```
|
||||
|
||||
Version 1.0.3:
|
||||
```
|
||||
Fix Attachment Object.
|
||||
```
|
||||
|
||||
Version 1.0.2:
|
||||
```
|
||||
Message delete & undelete actions added.
|
||||
Message delete & undelete actions added
|
||||
```
|
||||
|
||||
Version 1.0.1:
|
||||
|
|
@ -304,6 +283,6 @@ Initial Release.
|
|||
Acknowledgements
|
||||
----------------
|
||||
|
||||
© 2019, Clivern. Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
|
||||
© 2017, Clivern. Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
|
||||
|
||||
**Imap** is authored and maintained by [@clivern](http://github.com/clivern).
|
||||
**Imap** is authored and maintained by [@clivern](http://github.com/clivern).
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
{
|
||||
"name": "deblan/clivern-imap",
|
||||
"name": "clivern/imap",
|
||||
"type": "library",
|
||||
"description": "Access Mailbox Using PHP IMAP",
|
||||
"keywords": ["clivern", "imap"],
|
||||
"license": "MIT",
|
||||
"type": "project",
|
||||
"homepage": "https://github.com/clivern/imap",
|
||||
"authors": [
|
||||
{
|
||||
|
|
@ -16,9 +17,7 @@
|
|||
"php": ">=5.6.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "5.7.27",
|
||||
"friendsofphp/php-cs-fixer": "2.16.1",
|
||||
"squizlabs/php_codesniffer": "3.5.4"
|
||||
"phpunit/phpunit": "~5.7"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
@ -33,4 +32,4 @@
|
|||
"scripts": {
|
||||
"test": "phpunit"
|
||||
}
|
||||
}
|
||||
}
|
||||
2349
composer.lock
generated
2349
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset name="ImapCodingStandard">
|
||||
<description>Imap coding standard.</description>
|
||||
<file>src</file>
|
||||
<file>tests</file>
|
||||
<rule ref="PSR2" />
|
||||
</ruleset>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"extends": [
|
||||
"config:base"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core;
|
|||
use Clivern\Imap\Core\Exception\AuthenticationFailedException;
|
||||
|
||||
/**
|
||||
* Connection Class.
|
||||
* Connection Class
|
||||
*
|
||||
* @package Clivern\Imap\Core
|
||||
*/
|
||||
class Connection
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $server;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $port;
|
||||
|
||||
|
|
@ -60,7 +61,7 @@ class Connection
|
|||
protected $timeout;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $server
|
||||
* @param string $port
|
||||
|
|
@ -68,8 +69,9 @@ class Connection
|
|||
* @param string $password
|
||||
* @param string $flag
|
||||
* @param string $folder
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($server, $port, $email, $password, $flag = '/ssl', $folder = 'INBOX')
|
||||
public function __construct($server, $port, $email, $password, $flag = "/ssl", $folder = "INBOX")
|
||||
{
|
||||
$this->server = $server;
|
||||
$this->port = $port;
|
||||
|
|
@ -80,59 +82,55 @@ class Connection
|
|||
}
|
||||
|
||||
/**
|
||||
* Connect to IMAP Email.
|
||||
*
|
||||
* @throws AuthenticationFailedException
|
||||
* Connect to IMAP Email
|
||||
*
|
||||
* @return Connection
|
||||
* @throws AuthenticationFailedException
|
||||
*/
|
||||
public function connect()
|
||||
{
|
||||
try {
|
||||
$this->stream = imap_open(
|
||||
'{'.$this->server.':'.$this->port.$this->flag.'}'.$this->folder,
|
||||
$this->email,
|
||||
$this->password
|
||||
);
|
||||
$this->stream = imap_open("{" . $this->server . ":" . $this->port . $this->flag . "}" . $this->folder, $this->email, $this->password);
|
||||
} catch (\Exception $e) {
|
||||
throw new AuthenticationFailedException('Error! Connecting to Imap Email.');
|
||||
throw new AuthenticationFailedException("Error! Connecting to Imap Email.");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function reconnect($folder = 'INBOX')
|
||||
public function reconnect($folder = "INBOX")
|
||||
{
|
||||
try {
|
||||
imap_reopen($this->stream, '{'.$this->server.':'.$this->port.$this->flag.'}'.$folder);
|
||||
imap_reopen($this->stream, "{" . $this->server . ":" . $this->port . $this->flag . "}" . $folder);
|
||||
} catch (\Exception $e) {
|
||||
throw new AuthenticationFailedException('Error! Connecting to Imap Email.');
|
||||
throw new AuthenticationFailedException("Error! Connecting to Imap Email.");
|
||||
}
|
||||
}
|
||||
|
||||
public function survive($folder = 'INBOX')
|
||||
public function survive($folder = "INBOX")
|
||||
{
|
||||
if (!$this->ping() || ($this->folder !== $folder)) {
|
||||
if( !$this->ping() || ($this->folder != $folder) ) {
|
||||
$this->reconnect($folder);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Timeout.
|
||||
* Set Timeout
|
||||
*
|
||||
* @param string $timeout_type it may be IMAP_OPENTIMEOUT, IMAP_READTIMEOUT, IMAP_WRITETIMEOUT, or IMAP_CLOSETIMEOUT
|
||||
* @param int $timeout time in seconds or -1
|
||||
* @param integer $timeout time in seconds or -1
|
||||
* @return void
|
||||
*/
|
||||
public function setTimeout($timeout_type, $timeout)
|
||||
{
|
||||
$this->timeout_type = $timeout_type;
|
||||
$this->timeout = $timeout;
|
||||
|
||||
return (bool) imap_timeout($timeout_type, $timeout);
|
||||
return (boolean) imap_timeout($timeout_type, $timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Stream.
|
||||
* Get Stream
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
@ -142,7 +140,7 @@ class Connection
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Server.
|
||||
* Get Server
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -152,20 +150,19 @@ class Connection
|
|||
}
|
||||
|
||||
/**
|
||||
* Check Connection.
|
||||
* Check Connection
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function checkConnection()
|
||||
{
|
||||
return null !== $this->stream && imap_ping($this->stream);
|
||||
return (!is_null($this->stream) && imap_ping($this->stream));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Quota.
|
||||
*
|
||||
* @param string $folder
|
||||
* Get Quota
|
||||
*
|
||||
* @param string $folder
|
||||
* @return array
|
||||
*/
|
||||
public function getQuota($folder = 'INBOX')
|
||||
|
|
@ -174,21 +171,20 @@ class Connection
|
|||
|
||||
return [
|
||||
'usage' => (isset($data['usage'])) ? $data['usage'] : false,
|
||||
'limit' => (isset($data['limit'])) ? $data['limit'] : false,
|
||||
'limit' => (isset($data['limit'])) ? $data['limit'] : false
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Status.
|
||||
*
|
||||
* @param string $folder
|
||||
* @param string $flag
|
||||
* Get Status
|
||||
*
|
||||
* @param string $folder
|
||||
* @param string $flag
|
||||
* @return array
|
||||
*/
|
||||
public function getStatus($folder = 'INBOX', $flag = SA_ALL)
|
||||
{
|
||||
$data = imap_status($this->stream, '{'.$this->server.'}'.$folder, $flag);
|
||||
$data = imap_status($this->stream, "{" . $this->server . "}" . $folder, $flag);
|
||||
|
||||
return [
|
||||
'flags' => (isset($data->flags)) ? $data->flags : false,
|
||||
|
|
@ -196,12 +192,12 @@ class Connection
|
|||
'recent' => (isset($data->recent)) ? $data->recent : false,
|
||||
'unseen' => (isset($data->unseen)) ? $data->unseen : false,
|
||||
'uidnext' => (isset($data->uidnext)) ? $data->uidnext : false,
|
||||
'uidvalidity' => (isset($data->uidvalidity)) ? $data->uidvalidity : false,
|
||||
'uidvalidity' => (isset($data->uidvalidity)) ? $data->uidvalidity : false
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check MailBox Data.
|
||||
* Check MailBox Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
|
@ -214,22 +210,22 @@ class Connection
|
|||
'driver' => (isset($data->Driver)) ? $data->Driver : false,
|
||||
'mailbox' => (isset($data->Mailbox)) ? $data->Mailbox : false,
|
||||
'nmsgs' => (isset($data->Nmsgs)) ? $data->Nmsgs : false,
|
||||
'recent' => (isset($data->Recent)) ? $data->Recent : false,
|
||||
'recent' => (isset($data->Recent)) ? $data->Recent : false
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Ping Connection.
|
||||
* Ping Connection
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function ping()
|
||||
{
|
||||
return (bool) imap_ping($this->stream);
|
||||
return (boolean) imap_ping($this->stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Errors.
|
||||
* Get Errors
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
|
@ -237,11 +233,11 @@ class Connection
|
|||
{
|
||||
$errors = imap_errors();
|
||||
|
||||
return (\is_array($errors)) ? $errors : [];
|
||||
return (is_array($errors)) ? $errors : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Alerts.
|
||||
* Get Alerts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
|
@ -249,11 +245,11 @@ class Connection
|
|||
{
|
||||
$alerts = imap_alerts();
|
||||
|
||||
return (\is_array($alerts)) ? $alerts : [];
|
||||
return (is_array($alerts)) ? $alerts : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Last Error.
|
||||
* Get Last Error
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -265,24 +261,22 @@ class Connection
|
|||
}
|
||||
|
||||
/**
|
||||
* Disconnect.
|
||||
* Disconnect
|
||||
*
|
||||
* @param int $flag
|
||||
*
|
||||
* @return bool
|
||||
* @param integer $flag
|
||||
* @return boolean
|
||||
*/
|
||||
public function disconnect($flag = \CL_EXPUNGE)
|
||||
{
|
||||
if (null !== $this->stream && imap_ping($this->stream)) {
|
||||
if (imap_close($this->stream, $flag)) {
|
||||
if( !is_null($this->stream) && imap_ping($this->stream) ){
|
||||
if( imap_close($this->stream, $flag) ){
|
||||
$this->stream = null;
|
||||
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,25 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Exception;
|
||||
|
||||
/**
|
||||
* Connection Error Class.
|
||||
* Connection Error Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Exception
|
||||
*/
|
||||
class AuthenticationFailedException extends \Exception
|
||||
{
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $error
|
||||
*/
|
||||
public function __construct($error = null)
|
||||
{
|
||||
parent::__construct(sprintf('Authentication failed with error: %s', $error));
|
||||
parent::__construct(sprintf("Authentication failed with error: %s", $error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,25 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Exception;
|
||||
|
||||
/**
|
||||
* Folder Not Exist Error Class.
|
||||
* Folder Not Exist Error Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Exception
|
||||
*/
|
||||
class FolderNotExistException extends \Exception
|
||||
{
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $folder
|
||||
*/
|
||||
public function __construct($folder = null)
|
||||
{
|
||||
parent::__construct(sprintf('Mailbox folder not exist: %s', $folder));
|
||||
parent::__construct(sprintf("Mailbox folder not exist: %s", $folder));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,25 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Exception;
|
||||
|
||||
/**
|
||||
* Connection Error Class.
|
||||
* Connection Error Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Exception
|
||||
*/
|
||||
class MessageDeleteException extends \Exception
|
||||
{
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param int $message_number
|
||||
* @param integer $message_number
|
||||
*/
|
||||
public function __construct($message_number)
|
||||
{
|
||||
parent::__construct(sprintf('Message %s cannot be deleted', $message_number));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +1,26 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Exception;
|
||||
|
||||
/**
|
||||
* Connection Error Class.
|
||||
* Connection Error Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Exception
|
||||
*/
|
||||
class MessageDoesNotExistException extends \Exception
|
||||
{
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param int $number
|
||||
* @param integer $number
|
||||
* @param string $error
|
||||
*/
|
||||
public function __construct($number, $error)
|
||||
{
|
||||
parent::__construct(sprintf('Message %s does not exist: %s', $number, $error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +1,26 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Exception;
|
||||
|
||||
/**
|
||||
* Connection Error Class.
|
||||
* Connection Error Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Exception
|
||||
*/
|
||||
class MessageMoveException extends \Exception
|
||||
{
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param int $message_number
|
||||
* @param integer $message_number
|
||||
* @param string $mailbox
|
||||
*/
|
||||
public function __construct($message_number, $mailbox)
|
||||
{
|
||||
parent::__construct(sprintf('Message %s cannot be moved to %s', $message_number, $mailbox));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +1,20 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core;
|
||||
|
||||
use Clivern\Imap\Core\Connection;
|
||||
use Clivern\Imap\Core\Message\Header;
|
||||
use Clivern\Imap\Core\Message\Action;
|
||||
use Clivern\Imap\Core\Message\Attachment;
|
||||
use Clivern\Imap\Core\Message\Body;
|
||||
use Clivern\Imap\Core\Message\Header;
|
||||
|
||||
/**
|
||||
* Message Class.
|
||||
* Message Class
|
||||
*
|
||||
* @package Clivern\Imap\Core
|
||||
*/
|
||||
class Message
|
||||
{
|
||||
|
|
@ -43,17 +44,19 @@ class Message
|
|||
protected $body;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $uid;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $msg_number;
|
||||
|
||||
/**
|
||||
* Message Constructor.
|
||||
* Message Constructor
|
||||
*
|
||||
* @param Connection $connection
|
||||
*/
|
||||
public function __construct(Connection $connection, Header $header, Action $action, Body $body)
|
||||
{
|
||||
|
|
@ -64,11 +67,9 @@ class Message
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Message Number.
|
||||
*
|
||||
* @param int $id
|
||||
* @param mixed $msg_number
|
||||
* Set Message Number
|
||||
*
|
||||
* @param integer $id
|
||||
* @return Message
|
||||
*/
|
||||
public function setMsgNo($msg_number)
|
||||
|
|
@ -79,9 +80,9 @@ class Message
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Message Number.
|
||||
* Get Message Number
|
||||
*
|
||||
* @return int
|
||||
* @return integer
|
||||
*/
|
||||
public function getMsgNo()
|
||||
{
|
||||
|
|
@ -89,10 +90,9 @@ class Message
|
|||
}
|
||||
|
||||
/**
|
||||
* Set UID.
|
||||
*
|
||||
* @param int $uid
|
||||
* Set UID
|
||||
*
|
||||
* @param integer $uid
|
||||
* @return Message
|
||||
*/
|
||||
public function setUid($uid)
|
||||
|
|
@ -103,9 +103,9 @@ class Message
|
|||
}
|
||||
|
||||
/**
|
||||
* Get UID.
|
||||
* Get UID
|
||||
*
|
||||
* @return int
|
||||
* @return integer
|
||||
*/
|
||||
public function getUid()
|
||||
{
|
||||
|
|
@ -113,17 +113,17 @@ class Message
|
|||
}
|
||||
|
||||
/**
|
||||
* Config Message Number & UID.
|
||||
* Config Message Number & UID
|
||||
*
|
||||
* @return Message
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
if (!$this->msg_number && $this->uid) {
|
||||
if( !$this->msg_number && $this->uid ){
|
||||
$this->msg_number = imap_msgno($this->connection->getStream(), $this->uid);
|
||||
}
|
||||
|
||||
if (!$this->uid && $this->msg_number) {
|
||||
if( !$this->uid && $this->msg_number ){
|
||||
$this->uid = imap_uid($this->connection->getStream(), $this->msg_number);
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ class Message
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Message Header Object.
|
||||
* Get Message Header Object
|
||||
*
|
||||
* @return Header
|
||||
*/
|
||||
|
|
@ -141,7 +141,7 @@ class Message
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Message Action Object.
|
||||
* Get Message Action Object
|
||||
*
|
||||
* @return Action
|
||||
*/
|
||||
|
|
@ -151,7 +151,7 @@ class Message
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Message Body Object.
|
||||
* Get Message Body Object
|
||||
*
|
||||
* @return Body
|
||||
*/
|
||||
|
|
@ -161,13 +161,13 @@ class Message
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Message Attachments.
|
||||
* Get Message Attachments
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attachments()
|
||||
{
|
||||
if (null !== $this->attachments) {
|
||||
if( !is_null($this->attachments) ){
|
||||
return $this->attachments;
|
||||
}
|
||||
|
||||
|
|
@ -180,22 +180,21 @@ class Message
|
|||
|
||||
$i = 0;
|
||||
foreach ($structure->parts as $index => $part) {
|
||||
if (!$part->ifdisposition) {
|
||||
if (!$part->ifdisposition){
|
||||
continue;
|
||||
}
|
||||
$this->attachments[$i] = new Attachment($this->connection);
|
||||
$this->attachments[$i]->config($this->getMsgNo(), $this->getUid(), $index + 1, $part);
|
||||
++$i;
|
||||
$i += 1;
|
||||
}
|
||||
|
||||
return $this->attachments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Body.
|
||||
*
|
||||
* @param int $options
|
||||
* Get Body
|
||||
*
|
||||
* @param integer $options
|
||||
* @return string
|
||||
*/
|
||||
public function getBody($options = 0)
|
||||
|
|
@ -204,4 +203,4 @@ class Message
|
|||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Message;
|
||||
|
|
@ -10,27 +8,33 @@ namespace Clivern\Imap\Core\Message;
|
|||
use Clivern\Imap\Core\Connection;
|
||||
|
||||
/**
|
||||
* Action Class.
|
||||
* Action Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Message
|
||||
*/
|
||||
class Action
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Connection
|
||||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $message_number;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $message_uid;
|
||||
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param Connection $connection
|
||||
*/
|
||||
public function __construct(Connection $connection)
|
||||
{
|
||||
|
|
@ -38,11 +42,10 @@ class Action
|
|||
}
|
||||
|
||||
/**
|
||||
* Config Message.
|
||||
*
|
||||
* @param int $message_number
|
||||
* @param int $message_uid
|
||||
* Config Message
|
||||
*
|
||||
* @param integer $message_number
|
||||
* @param integer $message_uid
|
||||
* @return Action
|
||||
*/
|
||||
public function config($message_number, $message_uid)
|
||||
|
|
@ -54,22 +57,22 @@ class Action
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete Message.
|
||||
* Delete Message
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
return (bool) imap_delete($this->connection->getStream(), $this->message_uid, \FT_UID);
|
||||
return (boolean) imap_delete($this->connection->getStream(), $this->message_uid, \FT_UID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Undelete Message.
|
||||
* Undelete Message
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function undelete()
|
||||
{
|
||||
return (bool) imap_undelete($this->connection->getStream(), $this->message_uid, \FT_UID);
|
||||
return (boolean) imap_undelete($this->connection->getStream(), $this->message_uid, \FT_UID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Message;
|
||||
|
|
@ -10,22 +8,25 @@ namespace Clivern\Imap\Core\Message;
|
|||
use Clivern\Imap\Core\Connection;
|
||||
|
||||
/**
|
||||
* Attachment Class.
|
||||
* Attachment Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Message
|
||||
*/
|
||||
class Attachment
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Connection
|
||||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $message_number;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $message_uid;
|
||||
|
||||
|
|
@ -35,12 +36,15 @@ class Attachment
|
|||
protected $attachment;
|
||||
|
||||
/**
|
||||
* @var object
|
||||
* @var Object
|
||||
*/
|
||||
protected $part;
|
||||
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param Connection $connection
|
||||
*/
|
||||
public function __construct(Connection $connection)
|
||||
{
|
||||
|
|
@ -48,13 +52,12 @@ class Attachment
|
|||
}
|
||||
|
||||
/**
|
||||
* Config Attachment.
|
||||
* Config Attachment
|
||||
*
|
||||
* @param int $message_number
|
||||
* @param int $message_uid
|
||||
* @param int $attachment_id
|
||||
* @param integer $message_number
|
||||
* @param integer $message_uid
|
||||
* @param integer $attachment_id
|
||||
* @param object $part
|
||||
*
|
||||
* @return Attachment
|
||||
*/
|
||||
public function config($message_number, $message_uid, $attachment_id, $part)
|
||||
|
|
@ -70,11 +73,10 @@ class Attachment
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Attachment Property.
|
||||
*
|
||||
* @param string $key
|
||||
* @param bool $default
|
||||
* Get Attachment Property
|
||||
*
|
||||
* @param string $key
|
||||
* @param boolean $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = false)
|
||||
|
|
@ -83,7 +85,7 @@ class Attachment
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Filename.
|
||||
* Get Filename
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
@ -93,7 +95,7 @@ class Attachment
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Extension.
|
||||
* Get Extension
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
@ -103,7 +105,7 @@ class Attachment
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Size.
|
||||
* Get Size
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
@ -113,7 +115,7 @@ class Attachment
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Encoding.
|
||||
* Get Encoding
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
@ -123,7 +125,7 @@ class Attachment
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Bytes.
|
||||
* Get Bytes
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
@ -133,52 +135,49 @@ class Attachment
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Plain Body.
|
||||
* Get Plain Body
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPlainBody()
|
||||
{
|
||||
if ($this->get('plain_body')) {
|
||||
if( $this->get('plain_body') ){
|
||||
return $this->get('plain_body');
|
||||
}
|
||||
|
||||
$this->attachment['plain_body'] = imap_fetchbody(
|
||||
$this->connection->getStream(),
|
||||
$this->message_number,
|
||||
$this->attachment['index']
|
||||
);
|
||||
$this->attachment['plain_body'] = imap_fetchbody($this->connection->getStream(), $this->message_number, $this->attachment['index']);
|
||||
|
||||
return $this->get('plain_body');
|
||||
return $this->get('plain_body');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Body.
|
||||
*
|
||||
* @throws Exception
|
||||
* Get Body
|
||||
*
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getBody()
|
||||
{
|
||||
if ($this->get('body')) {
|
||||
|
||||
if( $this->get('body') ){
|
||||
return $this->get('body');
|
||||
}
|
||||
|
||||
switch ($this->getEncoding()) {
|
||||
case 0: // 7BIT
|
||||
|
||||
case 1: // 8BIT
|
||||
|
||||
case 2: // BINARY
|
||||
$this->attachment['body'] = $this->getPlainBody();
|
||||
|
||||
return $this->get('body');
|
||||
|
||||
case 3: // BASE-64
|
||||
$this->attachment['body'] = base64_decode($this->getPlainBody(), true);
|
||||
|
||||
$this->attachment['body'] = base64_decode($this->getPlainBody());
|
||||
return $this->get('body');
|
||||
|
||||
case 4: // QUOTED-PRINTABLE
|
||||
$this->attachment['body'] = imap_qprint($this->getPlainBody());
|
||||
|
||||
return $this->get('body');
|
||||
}
|
||||
|
||||
|
|
@ -186,59 +185,57 @@ class Attachment
|
|||
}
|
||||
|
||||
/**
|
||||
* Store File.
|
||||
* Store File
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $file_name
|
||||
*
|
||||
* @return bool
|
||||
* @param string $path
|
||||
* @param boolean $file_name
|
||||
* @return boolean
|
||||
*/
|
||||
public function store($path, $file_name = false)
|
||||
{
|
||||
$file_name = ($file_name) ? $file_name : "{$this->getFilename()}.{$this->getExtension()}";
|
||||
$path = rtrim($path, '/').'/';
|
||||
|
||||
return (bool) file_put_contents($path.$file_name, $this->getBody());
|
||||
$path = rtrim($path, '/') . "/";
|
||||
return (boolean) file_put_contents($path . $file_name, $this->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse Parts.
|
||||
* Parse Parts
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
protected function parseParts()
|
||||
{
|
||||
if ((\count($this->attachment) > 2)) {
|
||||
if( (count($this->attachment) > 2) ){
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->attachment['type'] = (isset($this->part->type)) ? $this->part->type : false;
|
||||
$this->attachment['encoding'] = (isset($this->part->encoding)) ? $this->part->encoding : false;
|
||||
$this->attachment['ifsubtype'] = (isset($this->part->ifsubtype)) ? $this->part->ifsubtype : false;
|
||||
$this->attachment['subtype'] = (isset($this->part->subtype)) ? $this->part->subtype : false;
|
||||
$this->attachment['ifdescription'] = (isset($this->part->ifdescription)) ? $this->part->ifdescription : false;
|
||||
$this->attachment['ifid'] = (isset($this->part->ifid)) ? $this->part->ifid : false;
|
||||
$this->attachment['id'] = (isset($this->part->id)) ? $this->part->id : false;
|
||||
$this->attachment['bytes'] = (isset($this->part->bytes)) ? $this->part->bytes : false;
|
||||
$this->attachment['size'] = (isset($this->part->bytes)) ? $this->part->bytes : false;
|
||||
$this->attachment['ifdisposition'] = (isset($this->part->ifdisposition)) ? $this->part->ifdisposition : false;
|
||||
$this->attachment['disposition'] = (isset($this->part->disposition)) ? $this->part->disposition : false;
|
||||
$this->attachment['ifdparameters'] = (isset($this->part->ifdparameters)) ? $this->part->ifdparameters : false;
|
||||
$this->attachment['ifparameters'] = (isset($this->part->ifparameters)) ? $this->part->ifparameters : false;
|
||||
$this->attachment['type'] = $this->part->type;
|
||||
$this->attachment['encoding'] = $this->part->encoding;
|
||||
$this->attachment['ifsubtype'] = $this->part->ifsubtype;
|
||||
$this->attachment['subtype'] = $this->part->subtype;
|
||||
$this->attachment['ifdescription'] = $this->part->ifdescription;
|
||||
$this->attachment['ifid'] = $this->part->ifid;
|
||||
$this->attachment['id'] = $this->part->id;
|
||||
$this->attachment['bytes'] = $this->part->bytes;
|
||||
$this->attachment['size'] = $this->part->bytes;
|
||||
$this->attachment['ifdisposition'] = $this->part->ifdisposition;
|
||||
$this->attachment['disposition'] = $this->part->disposition;
|
||||
$this->attachment['ifdparameters'] = $this->part->ifdparameters;
|
||||
$this->attachment['ifparameters'] = $this->part->ifparameters;
|
||||
|
||||
if (isset($this->part->dparameters) && \is_array($this->part->dparameters)) {
|
||||
if( is_array($this->part->dparameters) ){
|
||||
foreach ($this->part->dparameters as $obj) {
|
||||
if (\in_array(mb_strtolower($obj->attribute), ['filename', 'name'], true)) {
|
||||
$this->attachment[mb_strtolower($obj->attribute)] = pathinfo($obj->value, PATHINFO_FILENAME);
|
||||
if( in_array(strtolower($obj->attribute), ['filename', 'name']) ){
|
||||
$this->attachment[strtolower($obj->attribute)] = pathinfo($obj->value, PATHINFO_FILENAME);
|
||||
$this->attachment['extension'] = pathinfo($obj->value, PATHINFO_EXTENSION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->part->parameters) && \is_array($this->part->parameters)) {
|
||||
if( is_array($this->part->parameters) ){
|
||||
foreach ($this->part->parameters as $obj) {
|
||||
if (\in_array(mb_strtolower($obj->attribute), ['filename', 'name'], true)) {
|
||||
$this->attachment[mb_strtolower($obj->attribute)] = pathinfo($obj->value, PATHINFO_FILENAME);
|
||||
if( in_array(strtolower($obj->attribute), ['filename', 'name']) ){
|
||||
$this->attachment[strtolower($obj->attribute)] = pathinfo($obj->value, PATHINFO_FILENAME);
|
||||
$this->attachment['extension'] = pathinfo($obj->value, PATHINFO_EXTENSION);
|
||||
}
|
||||
}
|
||||
|
|
@ -246,4 +243,4 @@ class Attachment
|
|||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Message;
|
||||
|
|
@ -10,27 +8,30 @@ namespace Clivern\Imap\Core\Message;
|
|||
use Clivern\Imap\Core\Connection;
|
||||
|
||||
/**
|
||||
* Body Class.
|
||||
* Body Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Message
|
||||
*/
|
||||
class Body
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Connection
|
||||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $message_number;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $message_uid;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $encoding;
|
||||
|
||||
|
|
@ -39,8 +40,11 @@ class Body
|
|||
*/
|
||||
protected $message = '';
|
||||
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param Connection $connection
|
||||
*/
|
||||
public function __construct(Connection $connection)
|
||||
{
|
||||
|
|
@ -48,11 +52,10 @@ class Body
|
|||
}
|
||||
|
||||
/**
|
||||
* Config Body.
|
||||
*
|
||||
* @param int $message_number
|
||||
* @param int $message_uid
|
||||
* Config Body
|
||||
*
|
||||
* @param integer $message_number
|
||||
* @param integer $message_uid
|
||||
* @return Body
|
||||
*/
|
||||
public function config($message_number, $message_uid)
|
||||
|
|
@ -64,47 +67,44 @@ class Body
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Message.
|
||||
*
|
||||
* @param int $option
|
||||
* Get Message
|
||||
*
|
||||
* @param integer $option
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage($option = 2)
|
||||
{
|
||||
if (!empty($this->message)) {
|
||||
if( !empty($this->message) ){
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
$structure = imap_fetchstructure($this->connection->getStream(), $this->message_number);
|
||||
|
||||
if (isset($structure->parts) && \is_array($structure->parts) && isset($structure->parts[1])) {
|
||||
if(isset($structure->parts) && is_array($structure->parts) && isset($structure->parts[1])) {
|
||||
$part = $structure->parts[1];
|
||||
$this->message = imap_fetchbody($this->connection->getStream(), $this->message_number, $option);
|
||||
$this->message = imap_fetchbody($this->connection->getStream(),$this->message_number , $option);
|
||||
|
||||
$this->encoding = $part->encoding;
|
||||
|
||||
if (3 === $part->encoding) {
|
||||
if($part->encoding == 3) {
|
||||
$this->message = imap_base64($this->message);
|
||||
} elseif (1 === $part->encoding) {
|
||||
} elseif($part->encoding == 1) {
|
||||
$this->message = imap_8bit($this->message);
|
||||
} else {
|
||||
$this->message = imap_qprint($this->message);
|
||||
}
|
||||
} else {
|
||||
$this->message = imap_body($this->connection->getStream(), $this->message_number, $option);
|
||||
}
|
||||
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Encoding.
|
||||
* Get Encoding
|
||||
*
|
||||
* @return int
|
||||
* @return integer
|
||||
*/
|
||||
public function getEncoding()
|
||||
{
|
||||
return $this->encoding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Message;
|
||||
|
|
@ -10,22 +8,25 @@ namespace Clivern\Imap\Core\Message;
|
|||
use Clivern\Imap\Core\Connection;
|
||||
|
||||
/**
|
||||
* Header Class.
|
||||
* Header Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Message
|
||||
*/
|
||||
class Header
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Connection
|
||||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $message_number;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $message_uid;
|
||||
|
||||
|
|
@ -34,8 +35,11 @@ class Header
|
|||
*/
|
||||
protected $header = [];
|
||||
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param Connection $connection
|
||||
*/
|
||||
public function __construct(Connection $connection)
|
||||
{
|
||||
|
|
@ -43,17 +47,15 @@ class Header
|
|||
}
|
||||
|
||||
/**
|
||||
* Config Message.
|
||||
*
|
||||
* @param int $message_number
|
||||
* @param int $message_uid
|
||||
* @param mixed $options
|
||||
* Config Message
|
||||
*
|
||||
* @param integer $message_number
|
||||
* @param integer $message_uid
|
||||
* @return Header
|
||||
*/
|
||||
public function config($message_number, $message_uid, $options = 0)
|
||||
{
|
||||
if (!empty($this->header)) {
|
||||
if( !empty($this->header) ){
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -65,41 +67,37 @@ class Header
|
|||
}
|
||||
|
||||
/**
|
||||
* Get From Header.
|
||||
*
|
||||
* @param string $key
|
||||
* @param bool $default
|
||||
* Get From Header
|
||||
*
|
||||
* @param string $key
|
||||
* @param boolean $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = false)
|
||||
{
|
||||
return (isset($this->header[mb_strtolower($key)])) ? $this->header[mb_strtolower($key)] : $default;
|
||||
return (isset($this->header[strtolower($key)])) ? $this->header[strtolower($key)] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if header has key.
|
||||
* Check if header has key
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return bool
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
return isset($this->header[mb_strtolower($key)]);
|
||||
return (isset($this->header[strtolower($key)]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse Address List.
|
||||
* Parse Address List
|
||||
*
|
||||
* @param string $address_string
|
||||
* @param mixed $default_host
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function parseAddressList($address_string, $default_host = 'example.com')
|
||||
public function parseAddressList($address_string, $default_host = "example.com")
|
||||
{
|
||||
$address_array = imap_rfc822_parse_adrlist($address_string, $default_host);
|
||||
$address_array = imap_rfc822_parse_adrlist($address_string, $default_host);
|
||||
$address_list = [];
|
||||
|
||||
foreach ($address_array as $id => $val) {
|
||||
|
|
@ -107,7 +105,7 @@ class Header
|
|||
'mailbox' => $val->mailbox,
|
||||
'host' => $val->host,
|
||||
'personal' => $val->personal,
|
||||
'adl' => $val->adl,
|
||||
'adl' => $val->adl
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -115,10 +113,9 @@ class Header
|
|||
}
|
||||
|
||||
/**
|
||||
* Load Header Data.
|
||||
* Load Header Data
|
||||
*
|
||||
* @param mixed $options
|
||||
*
|
||||
* @return Header
|
||||
*/
|
||||
protected function load($options = 0)
|
||||
|
|
@ -132,8 +129,7 @@ class Header
|
|||
$this->header['date'] = (isset($item_overview->date)) ? $item_overview->date : false;
|
||||
$this->header['message_id'] = (isset($item_overview->message_id)) ? $item_overview->message_id : false;
|
||||
$this->header['in_reply_to'] = (isset($item_overview->in_reply_to)) ? $item_overview->in_reply_to : false;
|
||||
$this->header['references'] = (isset($item_overview->references)) ?
|
||||
explode(' ', $item_overview->references) : false;
|
||||
$this->header['references'] = (isset($item_overview->references)) ? explode(" ", $item_overview->references) : false;
|
||||
$this->header['size'] = (isset($item_overview->size)) ? $item_overview->size : false;
|
||||
$this->header['uid'] = (isset($item_overview->uid)) ? $item_overview->uid : false;
|
||||
$this->header['msgno'] = (isset($item_overview->msgno)) ? $item_overview->msgno : false;
|
||||
|
|
@ -148,4 +144,4 @@ class Header
|
|||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +1,34 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core;
|
||||
|
||||
use Clivern\Imap\Core\Message;
|
||||
use Clivern\Imap\Core\Connection;
|
||||
use Clivern\Imap\Core\Message\Header;
|
||||
use Clivern\Imap\Core\Message\Action;
|
||||
use Clivern\Imap\Core\Message\Body;
|
||||
use Clivern\Imap\Core\Message\Header;
|
||||
|
||||
/**
|
||||
* Message Iterator Class.
|
||||
* Message Iterator Class
|
||||
*
|
||||
* @package Clivern\Imap\Core
|
||||
*/
|
||||
class MessageIterator extends \ArrayIterator
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Connection
|
||||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Constructor
|
||||
*
|
||||
* @param Connection $connection
|
||||
* @param array $message_numbers
|
||||
*/
|
||||
public function __construct(Connection $connection, array $message_numbers)
|
||||
{
|
||||
|
|
@ -31,19 +37,13 @@ class MessageIterator extends \ArrayIterator
|
|||
}
|
||||
|
||||
/**
|
||||
* Get current message.
|
||||
* Get current message
|
||||
*
|
||||
* @return Message
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
$message = new Message(
|
||||
$this->connection,
|
||||
new Header($this->connection),
|
||||
new Action($this->connection),
|
||||
new Body($this->connection)
|
||||
);
|
||||
|
||||
$message = new Message($this->connection, new Header($this->connection), new Action($this->connection), new Body($this->connection));
|
||||
return $message->setUid(parent::current())->config();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core;
|
||||
|
|
@ -10,28 +8,22 @@ namespace Clivern\Imap\Core;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Search Class.
|
||||
* Search Class
|
||||
*
|
||||
* @package Clivern\Imap\Core
|
||||
*/
|
||||
class Search
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $conditions = [];
|
||||
|
||||
/**
|
||||
* Get Conditions Query.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (!empty($this->conditions)) ? implode(' ', $this->conditions) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Condition.
|
||||
* Add Condition
|
||||
*
|
||||
* @param Condition $condition
|
||||
* @return Search
|
||||
*/
|
||||
public function addCondition(Condition $condition)
|
||||
|
|
@ -42,7 +34,7 @@ class Search
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Conditions.
|
||||
* Get Conditions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
|
@ -50,4 +42,14 @@ class Search
|
|||
{
|
||||
return $this->conditions;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Conditions Query
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (!empty($this->conditions)) ? implode(" ", $this->conditions) : "";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* All Class.
|
||||
* All Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class All implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'ALL';
|
||||
return "ALL";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Answered Class.
|
||||
* Answered Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Answered implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'ANSWERED';
|
||||
return "ANSWERED";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* BCC Class.
|
||||
* BCC Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class BCC implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
|
|
@ -30,7 +31,7 @@ class BCC implements Condition
|
|||
}
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -38,4 +39,4 @@ class BCC implements Condition
|
|||
{
|
||||
return "BCC \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Before Class.
|
||||
* Before Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Before implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
|
|
@ -30,7 +31,7 @@ class Before implements Condition
|
|||
}
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -38,4 +39,4 @@ class Before implements Condition
|
|||
{
|
||||
return "BEFORE \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Body Class.
|
||||
* Body Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Body implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
|
|
@ -30,7 +31,7 @@ class Body implements Condition
|
|||
}
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -38,4 +39,4 @@ class Body implements Condition
|
|||
{
|
||||
return "BODY \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* CC Class.
|
||||
* CC Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class CC implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
|
|
@ -30,7 +31,7 @@ class CC implements Condition
|
|||
}
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -38,4 +39,4 @@ class CC implements Condition
|
|||
{
|
||||
return "CC \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Deleted Class.
|
||||
* Deleted Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Deleted implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'DELETED';
|
||||
return "DELETED";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Flagged Class.
|
||||
* Flagged Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Flagged implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'FLAGGED';
|
||||
return "FLAGGED";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* From Class.
|
||||
* From Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class From implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
|
|
@ -30,7 +31,7 @@ class From implements Condition
|
|||
}
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -38,4 +39,4 @@ class From implements Condition
|
|||
{
|
||||
return "FROM \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Keyword Class.
|
||||
* Keyword Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Keyword implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
|
|
@ -30,7 +31,7 @@ class Keyword implements Condition
|
|||
}
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -38,4 +39,4 @@ class Keyword implements Condition
|
|||
{
|
||||
return "KEYWORD \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* New Flag Class.
|
||||
* New Flag Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class NewFlag implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'NEW';
|
||||
return "NEW";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Old Class.
|
||||
* Old Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Old implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'OLD';
|
||||
return "OLD";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* On Class.
|
||||
* On Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class On implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
|
|
@ -30,7 +31,7 @@ class On implements Condition
|
|||
}
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -38,4 +39,4 @@ class On implements Condition
|
|||
{
|
||||
return "ON \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* All Class.
|
||||
* All Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Recent implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'RECENT';
|
||||
return "RECENT";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Seen Class.
|
||||
* Seen Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Seen implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'SEEN';
|
||||
return "SEEN";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Since Class.
|
||||
* Since Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Since implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
|
|
@ -30,7 +31,7 @@ class Since implements Condition
|
|||
}
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -38,4 +39,4 @@ class Since implements Condition
|
|||
{
|
||||
return "SINCE \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Subject Class.
|
||||
* Subject Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Subject implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
|
|
@ -30,7 +31,7 @@ class Subject implements Condition
|
|||
}
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -38,4 +39,4 @@ class Subject implements Condition
|
|||
{
|
||||
return "SUBJECT \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Text Class.
|
||||
* Text Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Text implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
|
|
@ -30,7 +31,7 @@ class Text implements Condition
|
|||
}
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -38,4 +39,4 @@ class Text implements Condition
|
|||
{
|
||||
return "TEXT \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* To Class.
|
||||
* To Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class To implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
|
|
@ -30,7 +31,7 @@ class To implements Condition
|
|||
}
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -38,4 +39,4 @@ class To implements Condition
|
|||
{
|
||||
return "TO \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* UnAnswered Class.
|
||||
* UnAnswered Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class UnAnswered implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'UNANSWERED';
|
||||
return "UNANSWERED";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* UnDeleted Class.
|
||||
* UnDeleted Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class UnDeleted implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'UNDELETED';
|
||||
return "UNDELETED";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* UnFlagged Class.
|
||||
* UnFlagged Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class UnFlagged implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'UNFLAGGED';
|
||||
return "UNFLAGGED";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* UnKeyword Class.
|
||||
* UnKeyword Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class UnKeyword implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
|
|
@ -30,7 +31,7 @@ class UnKeyword implements Condition
|
|||
}
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -38,4 +39,4 @@ class UnKeyword implements Condition
|
|||
{
|
||||
return "UNKEYWORD \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
|
@ -10,17 +8,20 @@ namespace Clivern\Imap\Core\Search\Condition;
|
|||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* UnSeen Class.
|
||||
* UnSeen Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class UnSeen implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* Query String.
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'UNSEEN';
|
||||
return "UNSEEN";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Contract;
|
||||
|
||||
/**
|
||||
* Condition Interface.
|
||||
* Condition Interface
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Contract
|
||||
*/
|
||||
interface Condition
|
||||
{
|
||||
public function __toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +1,28 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap;
|
||||
|
||||
use Clivern\Imap\Core\Connection;
|
||||
use Clivern\Imap\Core\Exception\FolderNotExistException;
|
||||
use Clivern\Imap\Core\Message;
|
||||
use Clivern\Imap\Core\Message\Action;
|
||||
use Clivern\Imap\Core\Message\Attachment;
|
||||
use Clivern\Imap\Core\Message\Body;
|
||||
use Clivern\Imap\Core\Message\Header;
|
||||
use Clivern\Imap\Core\MessageIterator;
|
||||
use Clivern\Imap\Core\Message;
|
||||
use Clivern\Imap\Core\Search;
|
||||
use Clivern\Imap\Core\Message\Header;
|
||||
use Clivern\Imap\Core\Message\Action;
|
||||
use Clivern\Imap\Core\Message\Attachments;
|
||||
use Clivern\Imap\Core\Message\Body;
|
||||
use Clivern\Imap\Core\Exception\FolderNotExistException;
|
||||
|
||||
/**
|
||||
* MailBox Class.
|
||||
* MailBox Class
|
||||
*
|
||||
* @package Clivern\Imap
|
||||
*/
|
||||
class MailBox
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -37,8 +38,9 @@ class MailBox
|
|||
*/
|
||||
protected $folders = [];
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Constructor
|
||||
*
|
||||
* @param Connection $connection IMAP connection
|
||||
*/
|
||||
|
|
@ -48,15 +50,14 @@ class MailBox
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Folder Name.
|
||||
* Set Folder Name
|
||||
*
|
||||
* @param string $folder
|
||||
*
|
||||
* @return MailBox
|
||||
*/
|
||||
public function setFolder($folder)
|
||||
{
|
||||
if (!\in_array($folder, $this->getFolders(), true)) {
|
||||
if( !in_array($folder, $this->getFolders()) ){
|
||||
throw new FolderNotExistException($folder);
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +67,7 @@ class MailBox
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Folder name.
|
||||
* Get Folder name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -76,22 +77,20 @@ class MailBox
|
|||
}
|
||||
|
||||
/**
|
||||
* Get number of messages in this mailbox.
|
||||
* Get number of messages in this mailbox
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
$this->connection->survive($this->folder);
|
||||
|
||||
return imap_num_msg($this->connection->getStream());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get message ids.
|
||||
* Get message ids
|
||||
*
|
||||
* @param Search $search
|
||||
*
|
||||
* @return MessageIterator
|
||||
*/
|
||||
public function getMessages(Search $search = null)
|
||||
|
|
@ -100,7 +99,7 @@ class MailBox
|
|||
$query = ($search) ? (string) $search : 'ALL';
|
||||
$message_numbers = imap_search($this->connection->getStream(), $query, \SE_UID);
|
||||
|
||||
if (false === $message_numbers) {
|
||||
if (false == $message_numbers) {
|
||||
// imap_search can also return false
|
||||
$message_numbers = [];
|
||||
}
|
||||
|
|
@ -109,61 +108,53 @@ class MailBox
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a message by message number or uid.
|
||||
*
|
||||
* @param bool|int $message_number
|
||||
* @param bool|int $message_uid
|
||||
* Get a message by message number or uid
|
||||
*
|
||||
* @param int|boolean $message_number
|
||||
* @param int|boolean $message_uid
|
||||
* @return Message
|
||||
*/
|
||||
public function getMessage($message_number = false, $message_uid = false)
|
||||
{
|
||||
$this->connection->survive($this->folder);
|
||||
|
||||
$message = new Message(
|
||||
$this->connection,
|
||||
new Header($this->connection),
|
||||
new Action($this->connection),
|
||||
new Attachment($this->connection),
|
||||
new Body($this->connection)
|
||||
);
|
||||
$message = new Message($this->connection, new Header($this->connection), new Action($this->connection), new Attachments($this->connection), new Body($this->connection));
|
||||
|
||||
if (false === $message_number) {
|
||||
if( $message_number == false ){
|
||||
return $message->setUid($message_uid)->config();
|
||||
}else{
|
||||
return $message->setMsgNo($message_number)->config();
|
||||
}
|
||||
|
||||
return $message->setMsgNo($message_number)->config();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all messages marked for deletion.
|
||||
* Delete all messages marked for deletion
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function expunge()
|
||||
{
|
||||
$this->connection->survive($this->folder);
|
||||
|
||||
return (bool) imap_expunge($this->connection->getStream());
|
||||
return (boolean) imap_expunge($this->connection->getStream());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Folders List.
|
||||
* Get Folders List
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFolders()
|
||||
{
|
||||
if (!empty($this->folders)) {
|
||||
if( !empty($this->folders) ){
|
||||
return $this->folders;
|
||||
}
|
||||
|
||||
$this->folders = imap_getmailboxes($this->connection->getStream(), '{'.$this->connection->getServer().'}', '*');
|
||||
$this->folders = imap_getmailboxes($this->connection->getStream(), "{" . $this->connection->getServer() . "}", "*");
|
||||
|
||||
foreach ($this->folders as $key => $folder) {
|
||||
$this->folders[$key] = str_replace('{'.$this->connection->getServer().'}', '', $folder->name);
|
||||
$this->folders[$key] = str_replace("{" . $this->connection->getServer() . "}", "", $folder->name);
|
||||
}
|
||||
|
||||
return $this->folders;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,4 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Tests\Core;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
|
@ -13,10 +7,10 @@ class ConnectionTest extends TestCase
|
|||
{
|
||||
public function testConnect()
|
||||
{
|
||||
//$email = getenv("TEST_EMAIL");
|
||||
//$password = getenv("TEST_EMAIL_PASS");
|
||||
//$connection = new \Clivern\Imap\Core\Connection("imap.gmail.com", "993", $email, $password, "/ssl", "INBOX");
|
||||
//$this->assertTrue($connection->connect()->checkConnection());
|
||||
//$this->assertTrue($connection->connect()->disconnect());
|
||||
$email = getenv("TEST_EMAIL");
|
||||
$password = getenv("TEST_EMAIL_PASS");
|
||||
$connection = new \Clivern\Imap\Core\Connection("imap.gmail.com", "993", $email, $password, "/ssl", "INBOX");
|
||||
$this->assertTrue($connection->connect()->checkConnection());
|
||||
$this->assertTrue($connection->connect()->disconnect());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,4 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Tests\Core;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
|
@ -14,32 +8,8 @@ class SearchTest extends TestCase
|
|||
public function testConditionBuilder()
|
||||
{
|
||||
$search = new \Clivern\Imap\Core\Search();
|
||||
$search->addCondition(new \Clivern\Imap\Core\Search\Condition\All())
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\Answered())
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\BCC('val'))
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\Before('val'))
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\Body('val'))
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\CC('val'))
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\Deleted())
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\Flagged())
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\From('val'))
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\Keyword('val'))
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\NewFlag())
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\Old())
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\On('val'))
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\Recent())
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\Seen())
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\Since('val'))
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\Subject('val'))
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\Text('val'))
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\To('val'))
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\UnAnswered())
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\UnDeleted())
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\UnFlagged())
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\UnKeyword('val'))
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\UnSeen());
|
||||
|
||||
$this->assertSame($search->getConditions(), [
|
||||
$search->addCondition(new \Clivern\Imap\Core\Search\Condition\All())->addCondition(new \Clivern\Imap\Core\Search\Condition\Answered())->addCondition(new \Clivern\Imap\Core\Search\Condition\BCC("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\Before("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\Body("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\CC("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\Deleted())->addCondition(new \Clivern\Imap\Core\Search\Condition\Flagged())->addCondition(new \Clivern\Imap\Core\Search\Condition\From("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\Keyword("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\NewFlag())->addCondition(new \Clivern\Imap\Core\Search\Condition\Old())->addCondition(new \Clivern\Imap\Core\Search\Condition\On("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\Recent())->addCondition(new \Clivern\Imap\Core\Search\Condition\Seen())->addCondition(new \Clivern\Imap\Core\Search\Condition\Since("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\Subject("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\Text("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\To("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\UnAnswered())->addCondition(new \Clivern\Imap\Core\Search\Condition\UnDeleted())->addCondition(new \Clivern\Imap\Core\Search\Condition\UnFlagged())->addCondition(new \Clivern\Imap\Core\Search\Condition\UnKeyword("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\UnSeen());
|
||||
$this->assertEquals($search->getConditions(), [
|
||||
'ALL',
|
||||
'ANSWERED',
|
||||
'BCC "val"',
|
||||
|
|
@ -63,13 +33,8 @@ class SearchTest extends TestCase
|
|||
'UNDELETED',
|
||||
'UNFLAGGED',
|
||||
'UNKEYWORD "val"',
|
||||
'UNSEEN',
|
||||
'UNSEEN'
|
||||
]);
|
||||
$this->assertSame(
|
||||
(string) $search,
|
||||
'ALL ANSWERED BCC "val" BEFORE "val" BODY "val" CC "val" DELETED FLAGGED FROM "val" KEYWORD "val" '.
|
||||
'NEW OLD ON "val" RECENT SEEN SINCE "val" SUBJECT "val" TEXT "val" TO "val" UNANSWERED UNDELETED '.
|
||||
'UNFLAGGED UNKEYWORD "val" UNSEEN'
|
||||
);
|
||||
$this->assertEquals((string) $search, 'ALL ANSWERED BCC "val" BEFORE "val" BODY "val" CC "val" DELETED FLAGGED FROM "val" KEYWORD "val" NEW OLD ON "val" RECENT SEEN SINCE "val" SUBJECT "val" TEXT "val" TO "val" UNANSWERED UNDELETED UNFLAGGED UNKEYWORD "val" UNSEEN');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imap PHP package.
|
||||
* (c) Clivern <hello@clivern.com>
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Tests;
|
||||
|
|
@ -10,7 +8,9 @@ namespace Tests;
|
|||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* MailBox Class Test.
|
||||
* MailBox Class Test
|
||||
*
|
||||
* @package Tests
|
||||
*/
|
||||
class MailBoxTest extends TestCase
|
||||
{
|
||||
|
|
@ -18,4 +18,4 @@ class MailBoxTest extends TestCase
|
|||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue