http://test.jamroom.net/index.php?m=index&o=index
the problem is escaping the ampersand character - everything I have
tried has not worked - I even tried using the spyc PHP YAML library:
http://code.google.com/p/spyc/
which can dump a PHP array as a valid YAML document, but even that
does not work - everything up to the first ampersand will come through
in the email, with the rest being missing. I've looked through the
YAML documentation, and it indicates that only ampersands at the
_beginning_ of a line need to be escaped - those in the middle of a
string do not need to be escaped. I've tried the following:
- enclosing the entire string in single quotes
- enclosing the entire string in double quotes
- enclosing the ampersand in single quotes
- enclosing the ampersand in double quotes
- enclosing the string in double quotes and the ampersand in single
quotes
- using a backslash before the ampersand with the string in double
quotes (the YAML documentation indicates that only strings enclosed in
double quotes can use a backslash as the escape operator).
none of this has worked. Is there something special I need to do to
ensure that ALL special characters are escaped properly? As a bit of
background - we have hundreds of email "templates" that get parsed,
and I am sending these over to Mad Mimi to a special promotion that
has a single replacement variable - {MESSAGEBODY} - that I am using as
the "placeholder" for the message to be placed in - this will make it
so we don't have to create hundreds of Mad Mimi promotions to handle
each template - we can instead have a single promotion with a single
variable in it that will contain the entire message. This makes it
important however to ensure all characters that need to be escaped are
escaped properly, so any help is appreciated.
Thanks for any assistance!
- Brian
Can you show me your code (off-list if you want to include the API key)?
<?php
require 'MadMailer.class.php';
$mail = new MadMailer('EMAIL_ADDRESS','API_KEY',false,true);
$body = "'http://test.jamroom.net/index.php?m=index&o=index'";
$rec = array(
'Email' => 'big...@jamroom.net'
);
$msg = array(
'Subject' => 'Test Subject',
'PromoName' => 'Jamroom Notifier',
'FromAddr' => 'sup...@jamroom.net'
);
$bod = array('MESSAGEBODY' => $body);
$txn = $mail->SendMessage($rec,$msg,$bod);
echo $txn;
?>
The email does get sent, but all I get in the body is:
http://test.jamroom.net/index.php?m=index
I've checked out the MadMailer class as well, and when it comes to
preparing the "body", it's pretty simple - it just does:
$request_string .= "&body=--- " . $this->construct_body($body_arr);
and construct_body() is:
function construct_body($body_data) {
foreach ($body_data as $key => $value) {
$body_string .= $key . ': ' . $value . "\n";
}
return $body_string;
}
there are no manipulations performed on $body_arr before being passed
into construct_body(), so I don't see how MadMailer could be affecting
it, although if it is the culprit I can likely just skip using it and
code it directly using curl.
Thanks!
- Brian
On Dec 29, 2:06 pm, Dave Hoover <dave.hoo...@gmail.com> wrote:
> Hm I just tried to use that URL in a {placeholder} and it worked fine for me.
>
> Can you show me your code (off-list if you want to include the API key)?
>
Thank you for checking it out - it is really appreciated. Having the
class handle all of the proper escaping (if needed) would be really
nice. Let me know if you need any additional info from me.
Thanks!
- Brian
On Dec 29, 3:32 pm, Nicholas Young <nicho...@nicholaswyoung.com>
wrote:
> Hi Brian,
>
> Let me see if I can duplicate your issue, and if so, I'll push out a patch
> to the class tonight.
>
> Nicholas Young
> nicho...@nicholaswyoung.com
> 615.727.2645 (Cell)
> 615.829.6687 (Main)http://nicholaswyoung.com
>
> On Tue, Dec 29, 2009 at 5:16 PM, Brian <jamr...@gmail.com> wrote:
> > Thanks for the help Dave - I should mention I am using MadMailer
> > (although I don't see anything being done as far as YAML escaping is
> > concerned) - here's the code:
>
> > <?php
> > require 'MadMailer.class.php';
>
> > $mail = new MadMailer('EMAIL_ADDRESS','API_KEY',false,true);
>
> > $body = "'http://test.jamroom.net/index.php?m=index&o=index'";
>
> > $rec = array(
> > 'Email' => 'big...@jamroom.net'
> > );
> > $msg = array(
> > 'Subject' => 'Test Subject',
> > 'PromoName' => 'Jamroom Notifier',
> > 'FromAddr' => 'supp...@jamroom.net'
- Brian
On Dec 29, 3:45 pm, Nicholas Young <nicho...@nicholaswyoung.com>
wrote:
> I just pushed out the fix. All I needed to do was urlencode the values...
> good catch!
>
> Thanks Brian!
>
> Nicholas Young
>
Thanks!
- Brian
On Dec 29, 3:53 pm, Nicholas Young <nicho...@nicholaswyoung.com>
wrote:
> That's what we're here for. :)
>
> Let me know if there's anything else you need.
>
> Nicholas Young
>
Nicholas Young
nich...@nicholaswyoung.com
615.727.2645 (Cell)
615.829.6687 (Main)
http://nicholaswyoung.com
Thanks!
- Brian
On Dec 29, 3:59 pm, Nicholas Young <nicho...@nicholaswyoung.com>
wrote:
> Hm. I don't know if I'm familiar with what you're talking about. Why
> don't you send across some examples (maybe off list) and I'll take a
> look at it.
>
> Nicholas Young
> nicho...@nicholaswyoung.com
> 615.727.2645 (Cell)
> 615.829.6687 (Main)http://nicholaswyoung.com
>