Skip to content

Commit

Permalink
Track bp-rbe-inbound-forum-attachments/vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
mikethicke committed Oct 2, 2024
1 parent 8010438 commit f9abec9
Show file tree
Hide file tree
Showing 183 changed files with 12,595 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_modules/
# ignore composer dependency directories
vendor/
!forked-plugins/ninja-forms-uploads/vendor/
!forked-plugins/bp-rbe-inbound-forum-attachments/vendor/
!themes/dahd-tainacan/**

# ignore log files and databases
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit9161dbb779a62d8efa2e2da26bcb9a39::getLoader();
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.idea
nbproject
/vendor
/example
/bin
composer.phar
.DS_Store
Thumbs.db
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7
- 7.1

before_script:
- composer install

script: phpunit
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 Dmitriy Bashkarev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
Faster MIME Mail Parser
=======================

Faster MIME Mail Parser could be used to parse emails in MIME format.

[![Build Status](https://travis-ci.org/bashkarev/email.svg?branch=master)](https://travis-ci.org/bashkarev/email)

# Usage

Basic usage is the following:

```php
$file = fopen('path/to/file.eml', 'r');
$message = \bashkarev\email\Parser::email($file);

$message->textHtml();

$message->getParts();
$message->getAttachments();
```

## Settings

There are settings available.

- `charset` - character set to use. Should be specified in uppercase only.
Default is `UTF-8`.

```php
\bashkarev\email\Parser::$charset = "WINDOWS-1251";
```

- `buffer` - read buffer size in bytes. Default is `500000`.

```php
\bashkarev\email\Parser::$buffer = 4096;
```

## Attachments

There is attachments parsing support.

### Saving attachments to files

Saving to files could be done as follows:

```php
$file = fopen('path/to/file.eml', 'rb');
$message = \bashkarev\email\Parser::email($file);
foreach ($message->getAttachments() as $attachment) {
$attachment->save('dir/' . $attachment->getFileName('undefined'));
}
```

### Streaming attachment to output

In order to stream attachment to output directly you need to do the following:

```php
$file = fopen('path/to/file.eml', 'rb');
$message = \bashkarev\email\Parser::email($file);
$attachment = $message->getAttachments()[0];
header("Content-Type: {$attachment->getMimeType()};");
header("Content-Disposition: attachment; filename=\"{$attachment->getFileName('undefined')}\"");
$attachment->getStream()->copy(fopen('php://output', 'c'));
```

## message/partial

```php
$block = \bashkarev\email\Parser::email([
fopen('path/to/part.1.eml', 'rb'),
fopen('path/to/part.2.eml', 'rb'),
]);
$block->getMessage();
```

## message/rfc822

```php
$file = fopen('path/to/file.eml', 'rb');
$container = \bashkarev\email\Parser::email($file);
$message = $container->getAttachments()[0]->getMessage();
```

## message/feedback-report
```php
$file = fopen('path/to/file.eml', 'rb');
$container = \bashkarev\email\Parser::email($file);
foreach ($container->getAttachments() as $attachment) {
if ($attachment->getMimeType() === 'message/feedback-report') {
/**
* @var \bashkarev\email\messages\Feedback $feedback
*/
$feedback = $attachment->getMessage();
$feedback->getType(); // Feedback::TYPE_ABUSE ...
}
}

```

## message/external-body

Supported types: url, local-file, ftp.

### FTP auth
```php
$file = fopen('path/to/file.eml', 'rb');
$container = \bashkarev\email\Parser::email($file);
foreach ($container->getAttachments() as $attachment) {
if ($attachment->getStream() instanceof \bashkarev\email\transports\Ftp) {
/**
* @var \bashkarev\email\transports\Ftp $transport
*/
$transport = $attachment->getStream();
$transport->username = 'username';
$transport->password = '******';
$attachment->save('dir/' . $attachment->getFileName('undefined'));
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "bashkarev/email",
"description": "Faster MIME Mail Parser could be used to parse emails in MIME format.",
"keywords": ["mime", "mail", "mailparse", "email", "mime-parser", "FBL", "ARF"],
"license": "MIT",
"authors": [
{
"name": "bashkarev",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.4",
"ext-mbstring": "*"
},
"autoload": {
"psr-4": {
"bashkarev\\email\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"bashkarev\\email\\tests\\": "tests/"
}
},
"require-dev": {
"phpunit/phpunit": "~4.4"
}
}
Loading

0 comments on commit f9abec9

Please sign in to comment.