How to read JSON main content

305 views
Skip to first unread message

Srinvias A

unread,
Mar 28, 2012, 7:46:56 AM3/28/12
to Postmark API Developers
Hi,

I am not finding the way to read the JSON mail content from the
Inbound Hook. I have created Inbound Hook using "http://requestb.in".

Anybody can help to find the way to read the JSON mails from Inbound
Hook.

Thanks & Regards,
Srinivas.

Milan Gornik

unread,
Mar 28, 2012, 11:06:46 AM3/28/12
to postmark-ap...@googlegroups.com
Hi Srinivas,

Can you describe your problem in more details?

One things comes to my mind instantly. Are you using PHP? Because most
people using PHP are confused that they can't read posted JSON. The
answer in that case is to read from raw http data. It's described
nicely here: http://www.codediesel.com/php/reading-raw-post-data-in-php/

Regards,
Milan Gornik
Postmark developer, Wildbit
http://twitter.com/milan_gornik

> --
> You received this message because you are subscribed to the Google Groups "Postmark API Developers" group.
> To post to this group, send email to postmark-ap...@googlegroups.com.
> To unsubscribe from this group, send email to postmark-api-deve...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/postmark-api-developers?hl=en.
>

Srinvias A

unread,
Mar 30, 2012, 1:18:28 AM3/30/12
to Postmark API Developers
Hi Milan,

Thank you very much for your reply.

I have done as follows,
I)
I have created Inbound Email Address:
385444e021f216bd...@inbound.postmarkapp.com

2) Created Inbound Hook using http://requestb.in

Inbound Hook - > http://requestb.in/rjyponrj

As per my understand any mails to
"385444e021f216bd...@inbound.postmarkapp.com" address
will be forwarded to Inbound hook "http://requestb.in/rjyponrj" in
JSON format.

Now I want to read the forwarded mail content should read from Inbound
Hook ( "http://requestb.in/rjyponrj")

I have seen the PHP examples, it looks like parsing the JSON format
files stored in a directory. But I want to read the JSON format mail
from Inbound Hook itself.

If am wrong please correct me.


Thanks & Regards,
Srinivas.

Joffrey Jaffeux

unread,
Mar 30, 2012, 5:45:06 AM3/30/12
to postmark-ap...@googlegroups.com
Use post mark inbound php library :
https://github.com/jjaffeux/postmark-inbound-php

Envoyé de mon iPhone

Srinvias A

unread,
Mar 30, 2012, 6:34:03 AM3/30/12
to Postmark API Developers
Hi Joffrey,

Thank you for your help.

Using that example I am trying to print the data from Inbound hook
"http://requestb.in/rjyponrj". as shown bellow

<?php>

$url = "http://requestb.in/rjyponrj";
$counter = 1;
while( $counter <= 10)
{
if(!@$data = file_get_contents($url))
{
echo "Unable to open $url";
exit;
}
else
{
echo "Success opening $url<br />";
}
echo $data;
sleep(5);
$counter = $counter + 1;
<?>

The response I am getting as follows:

ok
ok
ok
ok
ok
ok
ok
..
..

However, I am not getting actual mail content in JSON format.




Thanks & Regards,
Srinivas.

Joffrey Jaffeux

unread,
Mar 30, 2012, 9:24:36 AM3/30/12
to postmark-ap...@googlegroups.com
Hard to tell with your code because your are showing us the result of the request and not the request itself.
Joffrey JAFFEUX
06 19 99 76 60

JP Toto

unread,
Mar 30, 2012, 1:52:42 PM3/30/12
to postmark-ap...@googlegroups.com
You could also setup your own receiver server/hook directly, instead of relying on requestb.in. Will this be for a production application?

Srinvias A

unread,
Apr 9, 2012, 7:12:11 AM4/9/12
to Postmark API Developers
Thanks for your idea.
I had setup the my won inbound hook and able to read the mails in JSON
format from inbound hook.

I have another issue,

I am able to download attachment with small amount size(say 226 bytes
of image). If I am trying to download 1MB image file. Proper image is
not able to see after downloading that.

I am using Java to parse the JSON mail.

Any idea regarding this?

Thanks & Regards,
Srinivas.
> > *
> > Joffrey JAFFEUX
> > 06 19 99 76 60
> > *

Joffrey Jaffeux

unread,
Apr 9, 2012, 7:24:12 AM4/9/12
to postmark-ap...@googlegroups.com
Don't know java, byt you should watch your logs and see if you have any error, maybe something about input filesize or download time.

Srinvias A

unread,
Apr 9, 2012, 9:04:39 AM4/9/12
to Postmark API Developers
Could you please clarify the following queries

1) Is there any constraints on attachment size based on free and paid
postmark inbound account ?

Why I am asking this because, I am able to encode the 6MB size BASE64
decoded image using my Java API.
However, received from postmark app is giving improper encoding data
for large attachments.

For small size, it is giving properly.

Milan Gornik

unread,
Apr 9, 2012, 9:13:04 AM4/9/12
to postmark-ap...@googlegroups.com
Hi Srinivas,

There are no such limitations in Postmark based on free/paid account
type or by any other criteria. 10 MB is the overall limitation (for
any account) for the whole email. However, BASE64 encoding increases
file size by average rate of 37% percent, so that has to go into
account as well. Now, can you start a new support request by sending
an email to: sup...@postmarkapp.com ? In that support ticket, you can
present all the details of the messages you're processing. This is
most likely specific case, so we'll be able to handle it faster if
it's in the support system.

Kind regards,


Milan Gornik
Postmark developer, Wildbit
http://twitter.com/milan_gornik

Reply all
Reply to author
Forward
0 new messages