Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending form feed characters (\f) does not work #141

Closed
eiriksm opened this issue Aug 19, 2016 · 0 comments
Closed

Sending form feed characters (\f) does not work #141

eiriksm opened this issue Aug 19, 2016 · 0 comments

Comments

@eiriksm
Copy link
Contributor

eiriksm commented Aug 19, 2016

Hey. Not sure if this is a more general question or if I should report it here, but since this can be fixed in the php library (which i need) I am going to ask it here :)

Anyway, simple reproducible code:

<?php
require 'vendor/autoload.php';

use SparkPost\SparkPost;
use GuzzleHttp\Client;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;

$my_mail = 'me@mydomain.com';

$httpClient = new GuzzleAdapter(new Client());
$sparky = new SparkPost($httpClient, ['key'=>'xxx']);
$promise = $sparky->transmissions->post([
  'content' => [
    'from' => [
      'name' => 'test',
      'email' => $my_mail,
    ],
    'subject' => 'First Mailing From PHP',
    'html' => "\f",
    'text' => 'Congratulations, {{name}}!! You just sent your very first mailing!',
  ],
  'substitution_data' => ['name' => 'YOUR_FIRST_NAME'],
  'recipients' => [
    [
      'address' => [
        'name' => 'YOUR_NAME',
        'email' => $my_mail,
      ],
    ],
  ],
]);

try {
  $response = $promise->wait();
  echo "SUCCESS!\n";
  echo $response->getStatusCode()."\n";
  print_r($response->getBody())."\n";
} catch (\Exception $e) {
  echo "FAIL!\n";
  echo $e->getCode()."\n";
  echo $e->getMessage()."\n";
}

Expected result is to be sent successfully. Output is:

FAIL!
422
{ "errors": [ { "message": "invalid data format\/type", "description": "Problems parsing request as json", "code": "1300" } ] }

The issue also persists if you have the character somewhere inside your string too. Or just as any part of what ends up in the JSON, for example the sender or subject.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants