Comments (3)
Did the same to "fix" this issue, please take a look into it and make a proper fix?
from fetch.
Feel free to make a pull request.
from fetch.
I wrapped that line in isset
Attachment.php:101
if (isset($structure->bytes)) {
$this->size = $structure->bytes;
} else {
$this->size = 0; // _mysql complained on null so I made the size 0_
}
but now get some odd output and more attachments than were actually attached to the email
Here are my attachments
Number of attachments = 8 in total
Here is my debug code in this function
Attachment.php saveAS() function
/**
* This function saves the attachment to the exact specified location.
*
* @param string $path
* @return bool
*/
public function saveAs($path)
{
$encoding = $this->encoding;
$dirname = dirname($path);
if (file_exists($path)) {
if (!is_writable($path)) {
return false;
}
} elseif (!is_dir($dirname) || !is_writable($dirname)) {
return false;
}
if (($filePointer = fopen($path, 'w')) == false) {
return false;
}
**echo "ATTACHMENT.PHP saveAs() filePointer is $filePointer.\n";**
switch ($encoding) {
case 3: //base64
$streamFilter = stream_filter_append($filePointer, 'convert.base64-decode', STREAM_FILTER_WRITE);
break;
case 4: //quoted-printable
$streamFilter = stream_filter_append($filePointer, 'convert.quoted-printable-decode', STREAM_FILTER_WRITE);
break;
default:
$streamFilter = null;
}
Here is the debug output
[2016-11-23 09:12:48] [Email Bookings] Successfully created a new task with id [59607]
You have new mail in /var/mail/nadeem
iMac:seraph3 nadeem$ php artisan bookings:email
this size is 6451
this size is 16057
this size is 0
this size is 16057
this size is 0
this size is 51521
this size is 0
this size is 10799
this size is 0
this size is 14830
this size is 0
this size is 10644
this size is 0
this size is 6454
[2016-11-23 09:13:18] [Email Bookings] Message from staff
[2016-11-23 09:13:18] [Email Bookings] Preparing to book the message in from [email protected]
[2016-11-23 09:13:18] [Email Bookings] Searching for [email protected] within site users
Message.php getAttachments() filename is
[2016-11-23 09:13:18] [Email Bookings] Getting attachments
[2016-11-23 09:13:18] [Email Bookings] Has attachments
ATTACHMENT.PHP saveAs() filePointer is Resource id #748.
ATTACHMENT.PHP saveAs() filePointer is Resource id #750.
ATTACHMENT.PHP saveAs() filePointer is Resource id #751.
ATTACHMENT.PHP saveAs() filePointer is Resource id #752.
ATTACHMENT.PHP saveAs() filePointer is Resource id #753.
ATTACHMENT.PHP saveAs() filePointer is Resource id #754.
ATTACHMENT.PHP saveAs() filePointer is Resource id #755.
ATTACHMENT.PHP saveAs() filePointer is Resource id #756.
ATTACHMENT.PHP saveAs() filePointer is Resource id #757.
ATTACHMENT.PHP saveAs() filePointer is Resource id #758.
ATTACHMENT.PHP saveAs() filePointer is Resource id #759.
ATTACHMENT.PHP saveAs() filePointer is Resource id #760.
ATTACHMENT.PHP saveAs() filePointer is Resource id #761.
ATTACHMENT.PHP saveAs() filePointer is Resource id #762.
[2016-11-23 09:13:19] [Email Bookings] Successfully created a new task with id [59608]
and here are my attachments saved in my application.
It's hard to see exactly how many are being attached - there are 14 font awesome file/document icons and 17 delete icons (red x's) so does anybody have a clue why there are more attachments being created than actual real attachments?
I think it's got something to do with reading the structure of each section to find any attachments in each section.
Attachments.php:14
/**
* This library is a wrapper around the Imap library functions included in php. This class wraps around an attachment
* in a message, allowing developers to easily save or display attachments.
*
* @package Fetch
* @author Robert Hafner <[email protected]>
*/
class Attachment
{
/**
* This is the structure object for the piece of the message body that the attachment is located it.
*
* @var \stdClass
*/
protected $structure;
/**
* This is the unique identifier for the message this attachment belongs to.
*
* @var int
*/
protected $messageId;
/**
* This is the ImapResource.
*
* @var resource
*/
protected $imapStream;
/**
* This is the id pointing to the section of the message body that contains the attachment.
*
* @var int
*/
protected $partId;
/**
* This is the attachments filename.
*
* @var string
*/
protected $filename;
/**
* This is the size of the attachment.
*
* @var int
*/
protected $size;
/**
* This stores the data of the attachment so it doesn't have to be retrieved from the server multiple times. It is
* only populated if the getData() function is called and should not be directly used.
*
* @internal
* @var array
*/
protected $data;
Clearly the above variables show this file handles attachments.
Help would be appreciated!
PS. This function's comments are incomplete so it's not easy to understand
Message.php:702
/**
* This function returns the attachments a message contains. If a filename is passed then just that ImapAttachment
* is returned, unless
*
* @param null|string $filename
* @return array|bool|Attachment[]
*/
public function getAttachments($filename = null)
{
echo "Message.php getAttachments() filename is $filename\n";
// echo "Message.php getAttachments() this->attachments";
// print_r($this->attachments);
// echo "\n";
if (!isset($this->attachments) || count($this->attachments) < 1)
return false;
if (!isset($filename))
return $this->attachments;
$results = array();
foreach ($this->attachments as $attachment) {
if ($attachment->getFileName() == $filename)
$results[] = $attachment;
}
switch (count($results)) {
case 0:
return false;
case 1:
return array_shift($results);
default:
return $results;
break;
}
}
from fetch.
Related Issues (20)
- Allow get raw unparsed message (with all headers and body) HOT 1
- getMessages() should allow pagination, not only limit
- I'm having problems with koi8-r encoded messages HOT 3
- two issues found and corrected HOT 1
- Fetching More than 100 Email, Response is very slow.
- An empty file in the attachment generates false instead of the whole Message
- Call to undefined function Fetch\imap_num_msg() HOT 1
- Invalid cert on site HOT 2
- What happened to the channel?
- Insecure default connection flags
- Change setFileName() method from protected to public
- oAuth authentication HOT 4
- Open Shared Inbox HOT 2
- Unable to add multiple flags HOT 1
- Moving message between 2 IMAP accounts HOT 1
- IMAP TLS on 143 with Plain Auth
- ErrorException: imap_savebody(): stream filter (convert.base64-decode): invalid byte sequence HOT 1
- Question about versioning on the Packagist. HOT 2
- attachment - only from the email body HOT 1
- Compatibility issue with PHP 8.3 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fetch.