Skip to content

Commit

Permalink
## v0.7.2 on 2016.04.15
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
ApexWire committed Apr 15, 2016
1 parent 08b8adb commit e2ec5ae
Show file tree
Hide file tree
Showing 13 changed files with 555 additions and 262 deletions.
68 changes: 68 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
apexwire/fetch changelog
---------------------------

## Under development


## 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 [#147](https://github.com/tedious/Fetch/pull/147) from linniksa/patch-mime-decoder
- Changes from the pull request [#151](https://github.com/tedious/Fetch/pull/151)

## v0.7.1 on 2 Aug 2015

- Merge pull request [#145](https://github.com/tedious/Fetch/pull/145) from tedious/supress_php_warning
- Suppressed imap_open warning

## v0.6.1 on 8 Jan 2015

- Merge pull request [#109](https://github.com/tedious/Fetch/pull/109) from tedious/release-0.6.1
- Changed function names for cs consistency


## v0.5.3 on 14 Mar 2014

- Merge pull request [#40](https://github.com/tedious/Fetch/pull/40) from bjornpost/fix-multipart-messagebody
- In a multipart email messageBody() keeps headers


## v0.5.2 on 21 Jan 2014

- Merge pull request [#33](https://github.com/tedious/Fetch/pull/33) from tedivm/testing_update
- Separate Mail Server Setup into Development Package


## v0.5.1 on 19 Dec 2013

- Removed autoloader reference


## v0.4.5 on 1 Dec 2013

- Merge pull request [#27](https://github.com/tedious/Fetch/pull/27) from ArabCoders/master
- fixed bug in getting reply_to addresses


## v0.4.4 on 28 Jul 2013

- Merge pull request [#19](https://github.com/tedious/Fetch/pull/19) from codyfletcher/master
- Added support for "bcc" as a type of processed object.


## v0.4.3 on 12 Jul 2013

- Merge pull request [#17](https://github.com/tedious/Fetch/pull/17) from abimus/fix/flags
- Fix behavior on Server::setFlag()


## v0.4.2 on 2 Jul 2013

- Added bug fixed.

## v0.4.1 on 26 Nov 2012

- First release since migrating to github
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2009, Robert Hafner
Copyright © 2016, ApexWire
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
69 changes: 26 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,50 @@
# Fetch [![Build Status](https://travis-ci.org/tedious/Fetch.svg?branch=master)](https://travis-ci.org/tedious/Fetch)
Fetch
=====

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

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

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

## Installing
> 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
```
sudo ln -s /etc/php5/mods-available/imap.ini /etc/php5/cli/conf.d/30-imap.ini
```
Запустить

### Composer

Installing Fetch can be done through a variety of methods, although Composer is
recommended.

Until Fetch reaches a stable API with version 1.0 it is recommended that you
review changes before even Minor updates, although bug fixes will always be
backwards compatible.

```
"require": {
"tedivm/fetch": "0.6.*"
}
```sh
php composer.phar require "apexwire/fetch" : "^0.7.2"
```

### Pear
или добавить

Fetch is also available through Pear.

```
$ pear channel-discover pear.tedivm.com
$ pear install tedivm/Fetch
```json
"apexwire/fetch": "^0.7.2"
```

### Github

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

## Применение

## Sample Usage

This is just a simple code to show how to access messages by using Fetch. It uses Fetch
own autoload, but it can (and should be, if applicable) replaced with the one generated
by composer.

Это лишь простой код, чтобы показать, как получить доступ к сообщениям с помощью Fetch. Он использует Fetch
собственный автозагрузка, но он может (и должен быть, если это применимо) заменяется генерируемому
композитором.

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


$messages = $server->getMessages();
/** @var $message \Fetch\Message */
foreach ($messages as $message) {
echo "Subject: {$message->getSubject()}\nBody: {$message->getMessageBody()}\n";
}
```

## Лицензия

Этот проект был выпущен под лицензией [BSD-3-Clause](LICENSE).
Подробнее [тут](http://choosealicense.com/licenses/bsd-3-clause).

Copyright © 2016, ApexWire

## License
## Выражение признательности

Fetch is licensed under the BSD License. See the LICENSE file for details.
- Проект является форком [Fetch](https://github.com/tedious/Fetch).
67 changes: 67 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Fetch [![Build Status](https://travis-ci.org/tedious/Fetch.svg?branch=master)](https://travis-ci.org/tedious/Fetch)

[![License](http://img.shields.io/packagist/l/tedivm/fetch.svg)](https://github.com/tedious/fetch/blob/master/LICENSE)
[![Latest Stable Version](http://img.shields.io/github/release/tedious/fetch.svg)](https://packagist.org/packages/tedivm/fetch)
[![Coverage Status](http://img.shields.io/coveralls/tedious/Fetch.svg)](https://coveralls.io/r/tedious/Fetch?branch=master)
[![Total Downloads](http://img.shields.io/packagist/dt/tedivm/fetch.svg)](https://packagist.org/packages/tedivm/fetch)

Fetch is a library for reading email and attachments, primarily using the POP
and IMAP protocols.


## Installing
> 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
```
sudo ln -s /etc/php5/mods-available/imap.ini /etc/php5/cli/conf.d/30-imap.ini
```

### Composer

Installing Fetch can be done through a variety of methods, although Composer is
recommended.

Until Fetch reaches a stable API with version 1.0 it is recommended that you
review changes before even Minor updates, although bug fixes will always be
backwards compatible.

```
"require": {
"tedivm/fetch": "0.6.*"
}
```

### Pear

Fetch is also available through Pear.

```
$ pear channel-discover pear.tedivm.com
$ pear install tedivm/Fetch
```

### Github

Releases of Fetch are available on [Github](https://github.com/tedious/Fetch/releases).


## Sample Usage

This is just a simple code to show how to access messages by using Fetch. It uses Fetch
own autoload, but it can (and should be, if applicable) replaced with the one generated
by composer.


$server = new \Fetch\Server('imap.example.com', 993);
$server->setAuthentication('dummy', 'dummy');


$messages = $server->getMessages();
/** @var $message \Fetch\Message */
foreach ($messages as $message) {
echo "Subject: {$message->getSubject()}\nBody: {$message->getMessageBody()}\n";
}


## License

Fetch is licensed under the BSD License. See the LICENSE file for details.
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
{
"name": "tedivm/fetch",
"name": "apexwire/fetch",
"description": "A PHP IMAP Library",
"keywords": ["email","imap","pop3"],
"homepage": "http://github.com/tedious/Fetch",
"homepage": "http://github.com/apexwire/Fetch",
"type": "library",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Robert Hafner",
"email": "[email protected]"
},
{
"name": "ApexWire",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.3.0",
"php": ">=5.4.0",
"ext-imap": "*"
},
"require-dev": {
Expand Down
31 changes: 19 additions & 12 deletions src/Fetch/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,19 @@ class Attachment
* attachment is located at, and the identifier for that body part. As a general rule you should not be creating
* instances of this yourself, but rather should get them from an ImapMessage class.
*
* @param Message $message
* @param Message $message
* @param \stdClass $structure
* @param string $partIdentifier
* @param string $partIdentifier
*/
public function __construct(Message $message, $structure, $partIdentifier = null)
{
$this->messageId = $message->getUid();
$this->messageId = $message->getUid();
$this->imapStream = $message->getImapBox()->getImapStream();
$this->structure = $structure;
$this->structure = $structure;

if (isset($partIdentifier))
if (isset($partIdentifier)) {
$this->partId = $partIdentifier;
}

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

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

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

if (isset($structure->subtype))
if (isset($structure->subtype)) {
$this->mimeType .= '/' . strtolower($structure->subtype);
}

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

$messageBody = Message::decode($messageBody, $this->encoding);
$this->data = $messageBody;
$this->data = $messageBody;
}

return $this->data;
Expand Down Expand Up @@ -178,8 +180,9 @@ public function saveToDirectory($path)
{
$path = rtrim($path, '/') . '/';

if (is_dir($path))
if (is_dir($path)) {
return $this->saveAs($path . $this->getFileName());
}

return false;
}
Expand All @@ -192,12 +195,12 @@ public function saveToDirectory($path)
*/
public function saveAs($path)
{
$dirname = dirname($path);
$dirName = dirname($path);
if (file_exists($path)) {
if (!is_writable($path)) {
return false;
}
} elseif (!is_dir($dirname) || !is_writable($dirname)) {
} elseif (!is_dir($dirName) || !is_writable($dirName)) {
return false;
}

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

case 4: //quoted-printable
$streamFilter = stream_filter_append($filePointer, 'convert.quoted-printable-decode', STREAM_FILTER_WRITE);
$streamFilter = stream_filter_append($filePointer, 'convert.quoted-printable-decode',
STREAM_FILTER_WRITE);
break;

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

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

if ($streamFilter) {
Expand All @@ -232,6 +236,9 @@ public function saveAs($path)
return $result;
}

/**
* @param $text
*/
protected function setFileName($text)
{
$this->filename = MIME::decode($text, Message::$charset);
Expand Down
2 changes: 1 addition & 1 deletion src/Fetch/MIME.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function decode($text, $targetCharset = 'utf-8')
foreach (imap_mime_header_decode($text) as $word) {
$ch = 'default' === $word->charset ? 'ascii' : $word->charset;

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

return $result;
Expand Down
Loading

0 comments on commit e2ec5ae

Please sign in to comment.