jjaffeux / postmark-inbound-php

Simple API wrapper for Postmark Inbound Hook
http://developer.postmarkapp.com/developer-inbound.html
MIT License
97 stars 20 forks source link

Large Attachments #3

Closed jsjohnstone closed 12 years ago

jsjohnstone commented 12 years ago

When playing with this library today, I've encountered some issues when working with large attachments.

In this case, 'large attachments' refers to anything over 5MB.

When the post is received at the web-hook, the PHP script will run but the library will fail to decode the JSON data.

I've made sure that the request is being received correctly by writing it out to a file after the PostmarkInbound processing has been completed.

This is written correctly, but anything that should be coming from the PostmarkInbound processing that I try and write out - i.e. $postmark->from_email - is not set.

Any idea why this would be happening? Is there a way to deal with larger attachments that doesn't knock the script over?

Even being able to identify a large attachment so we can send an email back to the sender advising we can't accept it would be awesome.

Cheers,

Jamie

jjaffeux commented 12 years ago

Hum, try to up php _max_executiontime

You could also watch your php logs and see if you can find an error.

jsjohnstone commented 12 years ago

I've tried both of those steps already - the script is executing for about 187 seconds at the moment, and the error logs are all clean.

Did a little more digging and have found the following:

1) the json object is empty - the initial public function __construct($json) { if(empty($json)) is returning empty. 2) as such, the attempts to work on the json data are returning: Notice: Trying to get property of non-object in [...]/postmark.php on line 52.

So it would appear that with these larger files, no data is being passed to the class... or data is being passed but it's not being picked up.

jjaffeux commented 12 years ago

OK thx for the data, I will try to find a solution during the night.

On 22 February 2012 19:47, jsjohnstone < reply@reply.github.com

wrote:

I've tried both of those steps already - the script is executing for about 187 seconds at the moment, and the error logs are all clean.

Did a little more digging and have found the following:

1) the json object is empty - the initial public function __construct($json) { if(empty($json)) is returning empty. 2) as such, the attempts to work on the json data are returning: Notice: Trying to get property of non-object in [...]/postmark.php on line 52.

So it would appear that with these larger files, no data is being passed to the class... or data is being passed but it's not being picked up.


Reply to this email directly or view it on GitHub:

https://github.com/jjaffeux/postmark-inbound-php/issues/3#issuecomment-4114510

Joffrey JAFFEUX 06 19 99 76 60

jjaffeux commented 12 years ago

@jsjohnstone I've just pushed an update. I have included unit test for it and decoding large files work. However I'm not sure it will work for you. If it doesn't it's something in your php.ini (memory, execution time...).

Let me know.

jsjohnstone commented 12 years ago

Thanks for your assistance. Turns out some variables were set too low:

post_max_size was set to 5MB and memory_limit was being exceeded (even though this was set to 99MB).

I've upped both of these and the script seems to be working perfectly.

Once again, thanks @jjaffeux ! :)