Re: Retrieve attachment from a Post - mailgun

2014-08-08 Thread Luke Rehmann

>
> Did you ever solve this? 
>
Thanks 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Retrieve attachment from a Post - mailgun

2013-03-22 Thread mday trades
I just responded, but I  should have reiterated the flow the the
application.   It's basically as follows:

1.  I send an email to mailgun
2.  Mailgun parses the message and POSTS it to my web page/controller over
HTTP
3.  My application has a single controller (no models or views) with one
method that currently only does this:
$this->log($this->request->data);
4.  I found a Ruby sample that seems to deal with this, but Cakephp is not.
 I am wondering if the cake request object is not handling the FILES
correctly. Here is that sample:

# enumerate through all attachments in the message and save
# them to disk with their original filenames:
for attachment in request.files.values():
attachment.filename
data = attachment.stream.read()
with open(attachment.filename, "w") as f:
f.write(data)

5.  Here is some additional information on the attachment fields from
mailgun.

attachment-xstringattached file (‘x’ stands for number of the attachment).
Attachments are handled as file uploads, encoded as multipart/form-data.
content-id-mapstringJSON-encoded dictionary which maps Content-ID (CID) of
each attachment to the corresponding attachment-x parameter. This allows
you to map posted attachments to tags like  in the message
body.

6.   Here is a dump of the request object received when a new message is
received.  Note that the [content-id-map] and [attachment-count] are both
there.   The [attachment-1] is also referenced in the [content-id-map]

***
[recipient] => testrecei...@ducksoup.mailgun.org

[sender] => mdaytra...@gmail.com

[subject] => SUBJECT OF MESSAGE

[from] => mdaytrades 

[Received] => from [192.168.0.12] (
CPE0026f336fc30-CM0026f336fc2d.cpe.net.cable.rogers.com. [99.233.238.184])
bymx.google.com with ESMTPS id wn10sm4453782igb.2.2013.03.20.03.01.59
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Mar 2013
03:02:00 -0700 (PDT)

[X-Envelope-From] => 

[Dkim-Signature] => v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com;
s=20120113;
h=x-received:from:content-type:subject:date:references:to:message-id
:mime-version:x-mailer; bh=z2IoCinGNl4lOcyJgDRZOTqqTbEmOXG+ftlhXIfSivI=;
b=G2IaZ6gPn9GtugTTrIErSWuIyo4Ad9uiUcsp/XpoxXQFBJ5T0CEwNznldIXI15vQ4Q
ND8G6wf1PGRWKURTD8nSb0TRSFInBqImAW5t3KnhXKt/WGEVNOajwfwTR3m2OiryZkG8
C5qA8YHNWQHS8j9rzXP0RNxY3T8MN7YmtrWEdcybMpfgxFFjFdyB0IEF5+KDhaJ0Nc/u
oCtdrsXU1rVZNp52uqdiCHrR/7Ca7rAwMP3rxQx6X7yXiBcSqu2Lp9pSmwkHhWnFoJcn
WnLWbEVRQgsg+qKy8OJHIexEvdJa7Bwo/nSuPs+IIWyFKhQzLOqb8dXgDcDsuqVV2oPt 8BKw==

[X-Received] => by 10.42.88.145 with SMTP id
c17mr13130362icm.47.1363773721513; Wed, 20 Mar 2013 03:02:01 -0700 (PDT)

[Return-Path] => 

[From] => mdaytrades 

[Content-Type] => multipart/alternative;
boundary="Apple-Mail=_EC882749-B764-43DB-9769-3F4850B978F3"

[Subject] => SUBJECT OF MESSAGE

[Date] => Wed, 20 Mar 2013 06:02:00 -0400

[References] => <8a01b27e-cd7d-4599-b1c5-f87bf8746...@gmail.com>

[To] => "testrecei...@ducksoup.mailgun.org" <
testrecei...@ducksoup.mailgun.org>

[Message-Id] => <9385ec89-5462-4ba1-93b9-9e4e8bec1...@gmail.com>

[Mime-Version] => 1.0 (Mac OS X Mail 6.3 \(1503\))

[X-Mailer] => Apple Mail (2.1503)

[X-Mailgun-Incoming] => Yes

[message-headers] => [["Received", "by luna.mailgun.net with SMTP mgrt
8784990917749; Wed, 20 Mar 2013 10:02:02 +"], ["X-Envelope-From", "<
mdaytra...@gmail.com>"], ["Received", "from mail-ie0-f180.google.com (
mail-ie0-f180.google.com [209.85.223.180]) bymxa.mailgun.org with ESMTP id
51498919.7f7908037770-in1; Wed, 20 Mar 2013 10:02:01 - (UTC)"],
["Received", "by mail-ie0-f180.google.comwith SMTP id a11so1597996iee.39
for ; Wed, 20 Mar 2013 03:02:01 -0700
(PDT)"], ["Dkim-Signature", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=
gmail.com; s=20120113;
h=x-received:from:content-type:subject:date:references:to:message-id
:mime-version:x-mailer; bh=z2IoCinGNl4lOcyJgDRZOTqqTbEmOXG+ftlhXIfSivI=;
b=G2IaZ6gPn9GtugTTrIErSWuIyo4Ad9uiUcsp/XpoxXQFBJ5T0CEwNznldIXI15vQ4Q
ND8G6wf1PGRWKURTD8nSb0TRSFInBqImAW5t3KnhXKt/WGEVNOajwfwTR3m2OiryZkG8
C5qA8YHNWQHS8j9rzXP0RNxY3T8MN7YmtrWEdcybMpfgxFFjFdyB0IEF5+KDhaJ0Nc/u
oCtdrsXU1rVZNp52uqdiCHrR/7Ca7rAwMP3rxQx6X7yXiBcSqu2Lp9pSmwkHhWnFoJcn
WnLWbEVRQgsg+qKy8OJHIexEvdJa7Bwo/nSuPs+IIWyFKhQzLOqb8dXgDcDsuqVV2oPt
8BKw=="], ["X-Received", "by 10.42.88.145 with SMTP id
c17mr13130362icm.47.1363773721513; Wed, 20 Mar 2013 03:02:01 -0700 (PDT)"],
["Return-Path", ""], ["Received", "from
[192.168.0.12] (CPE0026f336fc30-CM0026f336fc2d.cpe.net.cable.rogers.com.
[99.233.238.184]) bymx.google.com with ESMTPS id
wn10sm4453782igb.2.2013.03.20.03.01.59 (version=TLSv1
cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Mar 2013 03:02:00 -0700
(PDT)"], ["From", "mdaytrades "], ["Content-Type",
"multipart/alternative;
boundary=\"Apple-Mail=_EC882749-B764-43DB-9769-3F4850B978F3\""],
["Subject", "SUBJECT OF MESSAGE"], ["Date", "Wed, 20 Mar 2013 06:02:00
-0400"], ["References", "<8a01b27e-cd7d

Re: Retrieve attachment from a Post - mailgun

2013-03-20 Thread MDay
I just responded, but I  should have reiterated the flow the the 
application.   It's basically as follows:

1.  I send an email to mailgun
2.  Mailgun parses the message and POSTS it to my web page/controller over 
HTTP
3.  My application has a single controller (no models or views) with one 
method that currently only does this:
$this->log($this->request->data);
4.  I found a Ruby sample that seems to deal with this, but Cakephp is not. 
 I am wondering if the cake request object is not handling the FILES 
correctly. Here is that sample:

# enumerate through all attachments in the message and save
# them to disk with their original filenames:
for attachment in request.files.values():
attachment.filename
data = attachment.stream.read()
with open(attachment.filename, "w") as f:
f.write(data)

5.  Here is some additional information on the attachment fields from 
mailgun.

attachment-xstringattached file (‘x’ stands for number of the attachment). 
Attachments are handled as file uploads, encoded as multipart/form-data.
content-id-mapstringJSON-encoded dictionary which maps Content-ID (CID) of 
each attachment to the corresponding attachment-x parameter. This allows 
you to map posted attachments to tags like  in the message 
body.

6.   Here is a dump of the request object received when a new message is 
received.  Note that the [content-id-map] and [attachment-count] are both 
there.   The [attachment-1] is also referenced in the [content-id-map]

***
[recipient] => testrecei...@ducksoup.mailgun.org

[sender] => mdaytra...@gmail.com

[subject] => SUBJECT OF MESSAGE

[from] => mdaytrades 

[Received] => from [192.168.0.12] 
(CPE0026f336fc30-CM0026f336fc2d.cpe.net.cable.rogers.com. [99.233.238.184]) 
by mx.google.com with ESMTPS id wn10sm4453782igb.2.2013.03.20.03.01.59 
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Mar 2013 
03:02:00 -0700 (PDT)

[X-Envelope-From] => 

[Dkim-Signature] => v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; 
s=20120113; 
h=x-received:from:content-type:subject:date:references:to:message-id 
:mime-version:x-mailer; bh=z2IoCinGNl4lOcyJgDRZOTqqTbEmOXG+ftlhXIfSivI=; 
b=G2IaZ6gPn9GtugTTrIErSWuIyo4Ad9uiUcsp/XpoxXQFBJ5T0CEwNznldIXI15vQ4Q 
ND8G6wf1PGRWKURTD8nSb0TRSFInBqImAW5t3KnhXKt/WGEVNOajwfwTR3m2OiryZkG8 
C5qA8YHNWQHS8j9rzXP0RNxY3T8MN7YmtrWEdcybMpfgxFFjFdyB0IEF5+KDhaJ0Nc/u 
oCtdrsXU1rVZNp52uqdiCHrR/7Ca7rAwMP3rxQx6X7yXiBcSqu2Lp9pSmwkHhWnFoJcn 
WnLWbEVRQgsg+qKy8OJHIexEvdJa7Bwo/nSuPs+IIWyFKhQzLOqb8dXgDcDsuqVV2oPt 8BKw==

[X-Received] => by 10.42.88.145 with SMTP id 
c17mr13130362icm.47.1363773721513; Wed, 20 Mar 2013 03:02:01 -0700 (PDT)

[Return-Path] => 

[From] => mdaytrades 

[Content-Type] => multipart/alternative; 
boundary="Apple-Mail=_EC882749-B764-43DB-9769-3F4850B978F3"

[Subject] => SUBJECT OF MESSAGE

[Date] => Wed, 20 Mar 2013 06:02:00 -0400

[References] => <8a01b27e-cd7d-4599-b1c5-f87bf8746...@gmail.com>

[To] => "testrecei...@ducksoup.mailgun.org" 


[Message-Id] => <9385ec89-5462-4ba1-93b9-9e4e8bec1...@gmail.com>

[Mime-Version] => 1.0 (Mac OS X Mail 6.3 \(1503\))

[X-Mailer] => Apple Mail (2.1503)

[X-Mailgun-Incoming] => Yes

[message-headers] => [["Received", "by luna.mailgun.net with SMTP mgrt 
8784990917749; Wed, 20 Mar 2013 10:02:02 +"], ["X-Envelope-From", 
""], ["Received", "from mail-ie0-f180.google.com 
(mail-ie0-f180.google.com [209.85.223.180]) by mxa.mailgun.org with ESMTP 
id 51498919.7f7908037770-in1; Wed, 20 Mar 2013 10:02:01 - (UTC)"], 
["Received", "by mail-ie0-f180.google.com with SMTP id a11so1597996iee.39 
for ; Wed, 20 Mar 2013 03:02:01 -0700 
(PDT)"], ["Dkim-Signature", "v=1; a=rsa-sha256; c=relaxed/relaxed; 
d=gmail.com; s=20120113; 
h=x-received:from:content-type:subject:date:references:to:message-id 
:mime-version:x-mailer; bh=z2IoCinGNl4lOcyJgDRZOTqqTbEmOXG+ftlhXIfSivI=; 
b=G2IaZ6gPn9GtugTTrIErSWuIyo4Ad9uiUcsp/XpoxXQFBJ5T0CEwNznldIXI15vQ4Q 
ND8G6wf1PGRWKURTD8nSb0TRSFInBqImAW5t3KnhXKt/WGEVNOajwfwTR3m2OiryZkG8 
C5qA8YHNWQHS8j9rzXP0RNxY3T8MN7YmtrWEdcybMpfgxFFjFdyB0IEF5+KDhaJ0Nc/u 
oCtdrsXU1rVZNp52uqdiCHrR/7Ca7rAwMP3rxQx6X7yXiBcSqu2Lp9pSmwkHhWnFoJcn 
WnLWbEVRQgsg+qKy8OJHIexEvdJa7Bwo/nSuPs+IIWyFKhQzLOqb8dXgDcDsuqVV2oPt 
8BKw=="], ["X-Received", "by 10.42.88.145 with SMTP id 
c17mr13130362icm.47.1363773721513; Wed, 20 Mar 2013 03:02:01 -0700 (PDT)"], 
["Return-Path", ""], ["Received", "from 
[192.168.0.12] (CPE0026f336fc30-CM0026f336fc2d.cpe.net.cable.rogers.com. 
[99.233.238.184]) by mx.google.com with ESMTPS id 
wn10sm4453782igb.2.2013.03.20.03.01.59 (version=TLSv1 
cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Mar 2013 03:02:00 -0700 
(PDT)"], ["From", "mdaytrades "], ["Content-Type", 
"multipart/alternative; 
boundary=\"Apple-Mail=_EC882749-B764-43DB-9769-3F4850B978F3\""], 
["Subject", "SUBJECT OF MESSAGE"], ["Date", "Wed, 20 Mar 2013 06:02:00 
-0400"], ["References", 
"<8a01b27e-cd7d-45

Re: Retrieve attachment from a Post - mailgun

2013-03-20 Thread nickmi...@gmail.com
You can if you use behind the scenes iframes, there's jquery plugins for this.


Sent from my HTC

- Reply message -
From: "jeet bajaj" 
To: 
Subject: Retrieve attachment from a Post - mailgun
Date: Wed, Mar 20, 2013 05:01
You have not shown you code properly, as much as i am understanding you might 
be using ajax for submission of forms. Are you Posting form using Ajax??? If it 
is, then i will suggest you that ajax based form posting does not support file 
upload


On Tue, Mar 19, 2013 at 10:56 PM, MDay  wrote:

hi there - hoping someone can help me with a simple issue I have having with 
retrieving data from an HTTP Post.   I am using mailgun to post an email 
message to a simple method in my application...  Everything is working 
correctly except I can't get attachments out of the POST.  I noticed that the 
encoding is set as multipart/form-data and the support guys at mailgun 
indicated I had to use $FILES to retrieve the data from the post.   I am a bit 
of a newbie, so now I am lost..


Here is what my current code looks like:

$subject = $this->request->data('subject');   //THIS WORKS

$attachement_test1 = 
$this->request->data($_FILES['attachment-1']);  //THIS DOESN'T WORK

$attachement_test2 = 
$this->request->data('attachment-1');//THIS DOESN'T WORK EITHER

$this->log("New Message");

$this->log($subject);

$this->log($attachement_test1);

$this->log($attachement_test2);


Snip from the mailgun docs:



attachment-x
string
attached file (‘x’ stands for number of the attachment). Attachments are 
handled as file uploads, encoded as multipart/form-data.




-- 

Like Us on FaceBook https://www.facebook.com/CakePHP

Find us on Twitter http://twitter.com/CakePHP

 

--- 

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.

To post to this group, send email to cake-php@googlegroups.com.

Visit this group at http://groups.google.com/group/cake-php?hl=en.

For more options, visit https://groups.google.com/groups/opt_out.

 

 






-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Retrieve attachment from a Post - mailgun

2013-03-20 Thread AD7six
Show the result of debug ($this->request->data);

That will either answer the question for you or show the data isn't there 
to be accessed.

AD

On Tuesday, 19 March 2013 18:26:15 UTC+1, MDay wrote:
>
> hi there - hoping someone can help me with a simple issue I have having 
> with retrieving data from an HTTP Post.   I am using mailgun to post an 
> email message to a simple method in my application...  Everything is 
> working correctly except I can't get attachments out of the POST.  I 
> noticed that the encoding is set as multipart/form-data and the support 
> guys at mailgun indicated I had to use $FILES to retrieve the data from the 
> post.   I am a bit of a newbie, so now I am lost..
>
> Here is what my current code looks like:
>
> $subject = $this->request->data('subject');   //THIS WORKS
>
> $attachement_test1 = $this->request->data($_FILES['attachment-1']); 
>  //THIS DOESN'T WORK
>
> $attachement_test2 = $this->request->data('attachment-1');//THIS DOESN'T 
> WORK EITHER
>
> $this->log("New Message");
>
> $this->log($subject);
>
> $this->log($attachement_test1);
>
> $this->log($attachement_test2);
>
>
> Snip from the mailgun docs:
>
>
> attachment-xstringattached file (‘x’ stands for number of the 
> attachment). Attachments are handled as file uploads, encoded as 
> multipart/form-data.
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Retrieve attachment from a Post - mailgun

2013-03-19 Thread jeet bajaj
You have not shown you code properly, as much as i am understanding you
might be using ajax for submission of forms. Are you Posting form using
Ajax??? If it is, then i will suggest you that ajax based form posting does
not support file upload

On Tue, Mar 19, 2013 at 10:56 PM, MDay  wrote:

> hi there - hoping someone can help me with a simple issue I have having
> with retrieving data from an HTTP Post.   I am using mailgun to post an
> email message to a simple method in my application...  Everything is
> working correctly except I can't get attachments out of the POST.  I
> noticed that the encoding is set as multipart/form-data and the support
> guys at mailgun indicated I had to use $FILES to retrieve the data from the
> post.   I am a bit of a newbie, so now I am lost..
>
> Here is what my current code looks like:
>
> $subject = $this->request->data('subject');   //THIS WORKS
>
> $attachement_test1 = $this->request->data($_FILES['attachment-1']);
>  //THIS DOESN'T WORK
>
> $attachement_test2 = $this->request->data('attachment-1');//THIS DOESN'T
> WORK EITHER
>
> $this->log("New Message");
>
> $this->log($subject);
>
> $this->log($attachement_test1);
>
> $this->log($attachement_test2);
>
>
> Snip from the mailgun docs:
>
>
> attachment-xstringattached file (‘x’ stands for number of the
> attachment). Attachments are handled as file uploads, encoded as
> multipart/form-data.
>
>  --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.