Skip to content

Commit e2ec5ae

Browse files
committed
## v0.7.2 on 2016.04.15
- The minimum version of php 5.4 - Add rawBody in Message - Add changelog.md - README.md rename README_EN.md. Add README.md - russian - Merge pull request [tedious#147](tedious#147) from linniksa/patch-mime-decoder - Changes from the pull request [tedious#151](tedious#151)
1 parent 08b8adb commit e2ec5ae

File tree

13 files changed

+555
-262
lines changed

13 files changed

+555
-262
lines changed

CHANGELOG.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
apexwire/fetch changelog
2+
---------------------------
3+
4+
## Under development
5+
6+
7+
## v0.7.2 on 2016.04.15
8+
9+
- The minimum version of php 5.4
10+
- Add rawBody in Message
11+
- Add changelog.md
12+
- README.md rename README_EN.md. Add README.md - russian
13+
- Merge pull request [#147](https://github.com/tedious/Fetch/pull/147) from linniksa/patch-mime-decoder
14+
- Changes from the pull request [#151](https://github.com/tedious/Fetch/pull/151)
15+
16+
## v0.7.1 on 2 Aug 2015
17+
18+
- Merge pull request [#145](https://github.com/tedious/Fetch/pull/145) from tedious/supress_php_warning
19+
- Suppressed imap_open warning
20+
21+
## v0.6.1 on 8 Jan 2015
22+
23+
- Merge pull request [#109](https://github.com/tedious/Fetch/pull/109) from tedious/release-0.6.1
24+
- Changed function names for cs consistency
25+
26+
27+
## v0.5.3 on 14 Mar 2014
28+
29+
- Merge pull request [#40](https://github.com/tedious/Fetch/pull/40) from bjornpost/fix-multipart-messagebody
30+
- In a multipart email messageBody() keeps headers
31+
32+
33+
## v0.5.2 on 21 Jan 2014
34+
35+
- Merge pull request [#33](https://github.com/tedious/Fetch/pull/33) from tedivm/testing_update
36+
- Separate Mail Server Setup into Development Package
37+
38+
39+
## v0.5.1 on 19 Dec 2013
40+
41+
- Removed autoloader reference
42+
43+
44+
## v0.4.5 on 1 Dec 2013
45+
46+
- Merge pull request [#27](https://github.com/tedious/Fetch/pull/27) from ArabCoders/master
47+
- fixed bug in getting reply_to addresses
48+
49+
50+
## v0.4.4 on 28 Jul 2013
51+
52+
- Merge pull request [#19](https://github.com/tedious/Fetch/pull/19) from codyfletcher/master
53+
- Added support for "bcc" as a type of processed object.
54+
55+
56+
## v0.4.3 on 12 Jul 2013
57+
58+
- Merge pull request [#17](https://github.com/tedious/Fetch/pull/17) from abimus/fix/flags
59+
- Fix behavior on Server::setFlag()
60+
61+
62+
## v0.4.2 on 2 Jul 2013
63+
64+
- Added bug fixed.
65+
66+
## v0.4.1 on 26 Nov 2012
67+
68+
- First release since migrating to github

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Copyright (c) 2009, Robert Hafner
2+
Copyright © 2016, ApexWire
23
All rights reserved.
34

45
Redistribution and use in source and binary forms, with or without

README.md

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,50 @@
1-
# Fetch [![Build Status](https://travis-ci.org/tedious/Fetch.svg?branch=master)](https://travis-ci.org/tedious/Fetch)
1+
Fetch
2+
=====
23

3-
[![License](http://img.shields.io/packagist/l/tedivm/fetch.svg)](https://github.com/tedious/fetch/blob/master/LICENSE)
4-
[![Latest Stable Version](http://img.shields.io/github/release/tedious/fetch.svg)](https://packagist.org/packages/tedivm/fetch)
5-
[![Coverage Status](http://img.shields.io/coveralls/tedious/Fetch.svg)](https://coveralls.io/r/tedious/Fetch?branch=master)
6-
[![Total Downloads](http://img.shields.io/packagist/dt/tedivm/fetch.svg)](https://packagist.org/packages/tedivm/fetch)
4+
**Fetch это библиотека для чтения электронной почты и вложений, по протоколам POP и IMAP.**
75

8-
Fetch is a library for reading email and attachments, primarily using the POP
9-
and IMAP protocols.
6+
## Установка
107

8+
Предпочтительный способ установки расширения через [composer](http://getcomposer.org/download/).
119

12-
## Installing
13-
> N.b. A note on Ubuntu 14.04 (probably other Debian-based / Apt managed systems), the install of php5-imap does not enable the extension for CLI (possibly others as well), which can cause composer to report fetch requires ext-imap
14-
```
15-
sudo ln -s /etc/php5/mods-available/imap.ini /etc/php5/cli/conf.d/30-imap.ini
16-
```
10+
Запустить
1711

18-
### Composer
19-
20-
Installing Fetch can be done through a variety of methods, although Composer is
21-
recommended.
22-
23-
Until Fetch reaches a stable API with version 1.0 it is recommended that you
24-
review changes before even Minor updates, although bug fixes will always be
25-
backwards compatible.
26-
27-
```
28-
"require": {
29-
"tedivm/fetch": "0.6.*"
30-
}
12+
```sh
13+
php composer.phar require "apexwire/fetch" : "^0.7.2"
3114
```
3215

33-
### Pear
16+
или добавить
3417

35-
Fetch is also available through Pear.
36-
37-
```
38-
$ pear channel-discover pear.tedivm.com
39-
$ pear install tedivm/Fetch
18+
```json
19+
"apexwire/fetch": "^0.7.2"
4020
```
4121

42-
### Github
43-
44-
Releases of Fetch are available on [Github](https://github.com/tedious/Fetch/releases).
22+
в разделе "require" вашего composer.json
4523

24+
## Применение
4625

47-
## Sample Usage
48-
49-
This is just a simple code to show how to access messages by using Fetch. It uses Fetch
50-
own autoload, but it can (and should be, if applicable) replaced with the one generated
51-
by composer.
52-
26+
Это лишь простой код, чтобы показать, как получить доступ к сообщениям с помощью Fetch. Он использует Fetch
27+
собственный автозагрузка, но он может (и должен быть, если это применимо) заменяется генерируемому
28+
композитором.
5329

30+
```php
5431
$server = new \Fetch\Server('imap.example.com', 993);
5532
$server->setAuthentication('dummy', 'dummy');
5633

57-
5834
$messages = $server->getMessages();
5935
/** @var $message \Fetch\Message */
6036
foreach ($messages as $message) {
6137
echo "Subject: {$message->getSubject()}\nBody: {$message->getMessageBody()}\n";
6238
}
39+
```
40+
41+
## Лицензия
42+
43+
Этот проект был выпущен под лицензией [BSD-3-Clause](LICENSE).
44+
Подробнее [тут](http://choosealicense.com/licenses/bsd-3-clause).
6345

46+
Copyright © 2016, ApexWire
6447

65-
## License
48+
## Выражение признательности
6649

67-
Fetch is licensed under the BSD License. See the LICENSE file for details.
50+
- Проект является форком [Fetch](https://github.com/tedious/Fetch).

README_EN.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Fetch [![Build Status](https://travis-ci.org/tedious/Fetch.svg?branch=master)](https://travis-ci.org/tedious/Fetch)
2+
3+
[![License](http://img.shields.io/packagist/l/tedivm/fetch.svg)](https://github.com/tedious/fetch/blob/master/LICENSE)
4+
[![Latest Stable Version](http://img.shields.io/github/release/tedious/fetch.svg)](https://packagist.org/packages/tedivm/fetch)
5+
[![Coverage Status](http://img.shields.io/coveralls/tedious/Fetch.svg)](https://coveralls.io/r/tedious/Fetch?branch=master)
6+
[![Total Downloads](http://img.shields.io/packagist/dt/tedivm/fetch.svg)](https://packagist.org/packages/tedivm/fetch)
7+
8+
Fetch is a library for reading email and attachments, primarily using the POP
9+
and IMAP protocols.
10+
11+
12+
## Installing
13+
> N.b. A note on Ubuntu 14.04 (probably other Debian-based / Apt managed systems), the install of php5-imap does not enable the extension for CLI (possibly others as well), which can cause composer to report fetch requires ext-imap
14+
```
15+
sudo ln -s /etc/php5/mods-available/imap.ini /etc/php5/cli/conf.d/30-imap.ini
16+
```
17+
18+
### Composer
19+
20+
Installing Fetch can be done through a variety of methods, although Composer is
21+
recommended.
22+
23+
Until Fetch reaches a stable API with version 1.0 it is recommended that you
24+
review changes before even Minor updates, although bug fixes will always be
25+
backwards compatible.
26+
27+
```
28+
"require": {
29+
"tedivm/fetch": "0.6.*"
30+
}
31+
```
32+
33+
### Pear
34+
35+
Fetch is also available through Pear.
36+
37+
```
38+
$ pear channel-discover pear.tedivm.com
39+
$ pear install tedivm/Fetch
40+
```
41+
42+
### Github
43+
44+
Releases of Fetch are available on [Github](https://github.com/tedious/Fetch/releases).
45+
46+
47+
## Sample Usage
48+
49+
This is just a simple code to show how to access messages by using Fetch. It uses Fetch
50+
own autoload, but it can (and should be, if applicable) replaced with the one generated
51+
by composer.
52+
53+
54+
$server = new \Fetch\Server('imap.example.com', 993);
55+
$server->setAuthentication('dummy', 'dummy');
56+
57+
58+
$messages = $server->getMessages();
59+
/** @var $message \Fetch\Message */
60+
foreach ($messages as $message) {
61+
echo "Subject: {$message->getSubject()}\nBody: {$message->getMessageBody()}\n";
62+
}
63+
64+
65+
## License
66+
67+
Fetch is licensed under the BSD License. See the LICENSE file for details.

composer.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
{
2-
"name": "tedivm/fetch",
2+
"name": "apexwire/fetch",
33
"description": "A PHP IMAP Library",
44
"keywords": ["email","imap","pop3"],
5-
"homepage": "http://github.com/tedious/Fetch",
5+
"homepage": "http://github.com/apexwire/Fetch",
66
"type": "library",
77
"license": "BSD-3-Clause",
88
"authors": [
99
{
1010
"name": "Robert Hafner",
1111
"email": "[email protected]"
12+
},
13+
{
14+
"name": "ApexWire",
15+
"email": "[email protected]"
1216
}
1317
],
1418
"require": {
15-
"php": ">=5.3.0",
19+
"php": ">=5.4.0",
1620
"ext-imap": "*"
1721
},
1822
"require-dev": {

src/Fetch/Attachment.php

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,19 @@ class Attachment
7777
* attachment is located at, and the identifier for that body part. As a general rule you should not be creating
7878
* instances of this yourself, but rather should get them from an ImapMessage class.
7979
*
80-
* @param Message $message
80+
* @param Message $message
8181
* @param \stdClass $structure
82-
* @param string $partIdentifier
82+
* @param string $partIdentifier
8383
*/
8484
public function __construct(Message $message, $structure, $partIdentifier = null)
8585
{
86-
$this->messageId = $message->getUid();
86+
$this->messageId = $message->getUid();
8787
$this->imapStream = $message->getImapBox()->getImapStream();
88-
$this->structure = $structure;
88+
$this->structure = $structure;
8989

90-
if (isset($partIdentifier))
90+
if (isset($partIdentifier)) {
9191
$this->partId = $partIdentifier;
92+
}
9293

9394
$parameters = Message::getParametersFromStructure($structure);
9495

@@ -102,8 +103,9 @@ public function __construct(Message $message, $structure, $partIdentifier = null
102103

103104
$this->mimeType = Message::typeIdToString($structure->type);
104105

105-
if (isset($structure->subtype))
106+
if (isset($structure->subtype)) {
106107
$this->mimeType .= '/' . strtolower($structure->subtype);
108+
}
107109

108110
$this->encoding = $structure->encoding;
109111
}
@@ -122,7 +124,7 @@ public function getData()
122124
: imap_body($this->imapStream, $this->messageId, FT_UID);
123125

124126
$messageBody = Message::decode($messageBody, $this->encoding);
125-
$this->data = $messageBody;
127+
$this->data = $messageBody;
126128
}
127129

128130
return $this->data;
@@ -178,8 +180,9 @@ public function saveToDirectory($path)
178180
{
179181
$path = rtrim($path, '/') . '/';
180182

181-
if (is_dir($path))
183+
if (is_dir($path)) {
182184
return $this->saveAs($path . $this->getFileName());
185+
}
183186

184187
return false;
185188
}
@@ -192,12 +195,12 @@ public function saveToDirectory($path)
192195
*/
193196
public function saveAs($path)
194197
{
195-
$dirname = dirname($path);
198+
$dirName = dirname($path);
196199
if (file_exists($path)) {
197200
if (!is_writable($path)) {
198201
return false;
199202
}
200-
} elseif (!is_dir($dirname) || !is_writable($dirname)) {
203+
} elseif (!is_dir($dirName) || !is_writable($dirName)) {
201204
return false;
202205
}
203206

@@ -211,7 +214,8 @@ public function saveAs($path)
211214
break;
212215

213216
case 4: //quoted-printable
214-
$streamFilter = stream_filter_append($filePointer, 'convert.quoted-printable-decode', STREAM_FILTER_WRITE);
217+
$streamFilter = stream_filter_append($filePointer, 'convert.quoted-printable-decode',
218+
STREAM_FILTER_WRITE);
215219
break;
216220

217221
default:
@@ -220,7 +224,7 @@ public function saveAs($path)
220224

221225
// Fix an issue causing server to throw an error
222226
// See: https://github.com/tedious/Fetch/issues/74 for more details
223-
$fetch = imap_fetchbody($this->imapStream, $this->messageId, $this->partId ?: 1, FT_UID);
227+
imap_fetchbody($this->imapStream, $this->messageId, $this->partId ?: 1, FT_UID);
224228
$result = imap_savebody($this->imapStream, $filePointer, $this->messageId, $this->partId ?: 1, FT_UID);
225229

226230
if ($streamFilter) {
@@ -232,6 +236,9 @@ public function saveAs($path)
232236
return $result;
233237
}
234238

239+
/**
240+
* @param $text
241+
*/
235242
protected function setFileName($text)
236243
{
237244
$this->filename = MIME::decode($text, Message::$charset);

src/Fetch/MIME.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static function decode($text, $targetCharset = 'utf-8')
3737
foreach (imap_mime_header_decode($text) as $word) {
3838
$ch = 'default' === $word->charset ? 'ascii' : $word->charset;
3939

40-
$result .= iconv($ch, $targetCharset, $word->text);
40+
$result .= Message::charsetConvert($word->text, $ch, $targetCharset) ?: $word->text;
4141
}
4242

4343
return $result;

0 commit comments

Comments
 (0)