sendgrid / sendgrid-php

The Official Twilio SendGrid PHP API Library
https://sendgrid.com
MIT License
1.49k stars 623 forks source link

Populate html_content with a full html page #1051

Closed LudovicFauchet closed 3 years ago

LudovicFauchet commented 3 years ago

Hello

I try to create a singlesends with a full html code as html_content, i use a html code generate with mjml.

Here my code :

$apiKey = SENDGRIP_API;
$sg = new \SendGrid($apiKey);
ob_start();
    include( get_template_directory() . '/newsletter/create-nl.php');
    $email_content = ob_get_contents();
ob_end_clean();
$before_concat = '{
  "send_to" : {
    "list_ids": [
      "my list id"
    ]
  },
  "email_config" : {
    "sender_id": 1758707,
    "html_content": "'.$email_content.'", 
    "plain_content": "Check out our spring line!",
    "subject" : "Mon test d\'envoi"
  },
  "name": "Envoi de test"
}';

$request_body = json_decode($before_concat);
echo($request_body);
$response = $sg->client->marketing()->singlesends()->post($request_body);
print_r($response->statusCode());
echo '<br>';
print_r($response->body());
echo '<br>';
print_r($response->headers());

So if i use just on html tag as html_content it works, but when i use my $email_content variable it's failed and i have a 500 error. I thinks it's due to the quotes in the html but i don't know how to format my html to be good to send in the json.

Cheers

thinkingserious commented 3 years ago

Hello @LudovicFauchet,

I suggest taking the output of $before_concat with the expanded $email_content included and running that output through a JSON validator.

With best regards,

Elmer

LudovicFauchet commented 3 years ago

Hello @thinkingserious

this my json return

{
    "send_to": {
        "list_ids": [
            "4bca2d3c-828e-427b-94b2-7d23c2ee87c0"
        ]
    },
    "email_config": {
        "sender_id": 1758707,
        "html_content": "<!doctype html><html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\"><head> <title></title>  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"> <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"> <style type=\"text/css\"> #outlook a { padding: 0; } .ReadMsgBody { width: 100%; } .ExternalClass { width: 100%; } .ExternalClass * { line-height: 100%; } body { margin: 0; padding: 0; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; } table, td { border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; } img { border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } p { display: block; margin: 13px 0; } </style>  <style type=\"text/css\"> @media only screen and (max-width:480px) { @-ms-viewport { width: 320px; } @viewport { width: 320px; } } </style>     <link href=\"https://fonts.googleapis.com/css?family=Montserrat:300,400,500,700\" rel=\"stylesheet\" type=\"text/css\"> <style type=\"text/css\"> @import url(https://fonts.googleapis.com/css?family=Montserrat:300,400,500,700); </style>  <style type=\"text/css\"> @media only screen and (min-width:480px) { .mj-column-per-100 { width: 100% !important; } .mj-column-per-50 { width: 50% !important; } } </style> <style type=\"text/css\"></style></head><body> <div>  <div style=\"Margin:0px auto;max-width:600px;\"> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width:100%;\"> <tbody> <tr> <td style=\"direction:ltr;font-size:0px;padding:40px 20px 0px 20px;text-align:center;vertical-align:top;\">  <div class=\"mj-column-per-100 outlook-group-fix\" style=\"font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align:top;padding:0px;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tr> <td align=\"center\" style=\"font-size:0px;padding:0px;padding-bottom:25px;word-break:break-word;\"> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"border-collapse:collapse;border-spacing:0px;\"> <tbody> <tr> <td style=\"width:216px;\"><a href=\"\" target=\"_blank\"><img alt=\"logo\" height=\"auto\" src=\"/wp-content/themes/riffx/emails/images/logo.png\" style=\"border:0;display:block;outline:none;text-decoration:none;width:100%;\" width=\"216\"></a></td> </tr> </tbody> </table> </td> </tr> </table> </td> </tr> </tbody> </table> </div>  </td> </tr> </tbody> </table> </div> <div style=\"margin: 0px auto; max-width: 545px\"> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 100%\"> <tbody> <tr> <td style=\"   direction: ltr; font-size: 0px; padding: 0px 15px;  text-align: center; \">   <div style=\"margin: 0px auto; max-width: 515px\"> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 100%\"> <tbody> <tr> <td style=\"    direction: ltr; font-size: 0px; padding: 0px;   text-align: center; \">   <div class=\"mj-column-per-100 mj-outlook-group-fix\" style=\"    font-size: 0px; text-align: left;   direction: ltr; display: inline-block;  vertical-align: top;    width: 100%;    \"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align: top; padding: 0px\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"\" width=\"100%\"> <tr> <td style=\"  font-size: 0px; padding: 10px 0;    word-break: break-word; \"> <p style=\" border-top: solid 1px #e6eaf1;  font-size: 1;   margin: 0px auto;   width: 100%;    \"></p>  </td> </tr> </table> </td> </tr> </tbody> </table> </div>   </td> </tr> </tbody> </table> </div>   <div style=\"margin: 0px auto; max-width: 515px\"> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 100%\"> <tbody> <tr> <td style=\"  direction: ltr; font-size: 0px; padding: 0px;   text-align: center; \">    <div class=\"mj-column-per-100 mj-outlook-group-fix\" style=\" font-size: 0px; text-align: left; direction: ltr; display: inline-block; vertical-align: top; width: 100%; \"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align: top; padding: 0px\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"\" width=\"100%\"> <tr> <td align=\"center\" style=\" font-size: 0px; padding: 0px; padding-top: 20px; word-break: break-word; \"> <div style=\" font-family: Montserrat, sans-serif; font-size: 16px; font-weight: 600; letter-spacing: -0.18px; line-height: 22px; text-align: center; color: #e17d1e; \"> LE CRÉDIT MUTUEL DONNE LE LA, 20 ANS D’ÉMOTION ET DE PARTAGE EN MUSIQUE </div> </td> </tr> </table> </td> </tr> </tbody> </table> </div>    <div class=\"mj-column-per-100 mj-outlook-group-fix\" style=\"  font-size: 0px; text-align: left;   direction: ltr; display: inline-block;  vertical-align: top;    width: 100%;    \"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\" vertical-align: top;    padding: 0px;   padding-top: 10px;  \"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"\" width=\"100%\"> <tr> <td align=\"center\" style=\" font-size: 0px; padding: 0px;   padding-top: 15px;  padding-bottom: 5px;    word-break: break-word; \"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"  border-collapse: collapse;  border-spacing: 0px;    \"> <tbody> <tr> <td style=\"width: 515px\"> <img height=\"auto\" src=\"t/uploads/2021/03/image-dillustration-20-ans-de-musique-riffx-1.jpg\" style=\"  border: 0;  display: block; outline: none;  text-decoration: none;  height: auto;   width: 100%;    font-size: 13px;    \" width=\"515\" /> </td> </tr> </tbody> </table> </td> </tr> <tr> <td align=\"center\" style=\"    font-size: 0px; padding: 0px;   padding-top: 15px;  word-break: break-word; \"> <div style=\"   font-family: Montserrat, sans-serif;    font-size: 13px;    font-weight: 300;   line-height: 20px;  text-align: center; color: #2f2d3c; \"> Chaque année, le Crédit Mutuel parraine plus de 600 évènements musicaux, près de 90 festivals et 26 salles de concert partout en France. Il aime tellement la musique qu’il a associé son nom à un festival, Le Printemps de Bourges Crédit Mutuel.<br /><br />Avec RIFFX by Crédit Mutuel, la plateforme musicale qui réunit ceux qui aiment et ceux qui font la musique, le Crédit Mutuel est activateur d’émotion. </div> </td> </tr> <tr> <td align=\"center\" vertical-align=\"middle\" style=\"   font-size: 0px; padding: 35px 0;    word-break: break-word; \"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"  border-collapse: separate;  line-height: 100%;  \"> <tr> <td align=\"center\" bgcolor=\"#E17D1E\" role=\"presentation\" style=\"    border: none;   border-radius: 3px; cursor: auto;   height: 50px;   mso-padding-alt: 0 25px;    background: #e17d1e;    \" valign=\"middle\"> <a href=\"https://riffx.fr/20-ans/\" style=\" display: inline-block;  background: #e17d1e;    color: #ffffff; font-family: Montserrat,    sans-serif; font-size: 11.5px;  font-weight: 700;   line-height: 120%;  margin: 0;  text-decoration: none;  text-transform: uppercase;  padding: 0 25px;    mso-padding-alt: 0px;   border-radius: 3px; \" target=\"_blank\"> En savoir plus </a> </td> </tr> </table> </td> </tr> </table> </td> </tr> </tbody> </table> </div>  </td> </tr> </tbody> </table> </div>   <div class=\"mj-column-per-100 mj-outlook-group-fix\" style=\" font-size: 0px; text-align: left;   direction: ltr; display: inline-block;  vertical-align: top;    width: 100%;    \"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align: top; padding: 0px\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"\" width=\"100%\"> <tr> <td style=\"  font-size: 0px; padding: 10px 0 10px 0; word-break: break-word; \"> <p style=\" border-top: solid 1px #e6eaf1;  font-size: 1;   margin: 0px auto;   width: 100%;    \"></p>  </td> </tr> </table> </td> </tr> </tbody> </table> </div>    <div class=\"mj-column-per-100 mj-outlook-group-fix\" style=\" font-size: 0px; text-align: left; direction: ltr; display: inline-block; vertical-align: top; width: 100%; \"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align: top; padding: 0px\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"\" width=\"100%\"> <tr> <td align=\"center\" style=\" font-size: 0px; padding: 0px; padding-top: 20px; word-break: break-word; \"> <div style=\" font-family: Montserrat, sans-serif; font-size: 16px; font-weight: 600; letter-spacing: -0.18px; line-height: 22px; text-align: center; color: #e17d1e; \"> Tomorrowland Around the World </div> </td> </tr> </table> </td> </tr> </tbody> </table> </div>   <div style=\"margin: 30px auto 0 auto; max-width: 515px\"> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 100%\"> <tbody> <tr> <td style=\" direction: ltr; font-size: 0px; padding: 0px; text-align: center; \">  <div class=\"mj-column-per-50 mj-outlook-group-fix\" style=\" font-size: 0px; text-align: left; direction: ltr; display: inline-block; vertical-align: top; width: 100%; \"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align: top; padding: 5px 15px\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"\" width=\"100%\"> <tr> <td align=\"center\" style=\" font-size: 0px; padding: 0px; word-break: break-word; \"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\" border-collapse: collapse; border-spacing: 0px; \"> <tbody> <tr> <td style=\"width: 227px\"> <img height=\"auto\" src=\"content/uploads/2021/07/tml.jpg\" style=\" border: 0; display: block; outline: none; text-decoration: none; height: auto; width: 100%; font-size: 13px; \" width=\"227\" /> </td> </tr> </tbody> </table> </td> </tr> </table> </td> </tr> </tbody> </table> </div>  <div class=\"mj-column-per-50 mj-outlook-group-fix\" style=\" font-size: 0px; text-align: left; direction: ltr; display: inline-block; vertical-align: top; width: 100%; \"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\" vertical-align: top; padding: 10px 0px 0px 0px; \"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"\" width=\"100%\"> <tr> <td align=\"left\" style=\" font-size: 0px; padding: 0px; word-break: break-word; \"> <div style=\" font-family: Montserrat, sans-serif; font-size: 13px; font-weight: 300; line-height: 20px; text-align: left; color: #2f2d3c; \"> </div> </td> </tr> </table> </td> </tr> </tbody> </table> </div>  </td> </tr> </tbody> </table> </div>   <div style=\"margin: 0px auto; max-width: 515px\"> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 100%\"> <tbody> <tr> <td style=\" direction: ltr; font-size: 0px; padding: 0px; text-align: center; \">  <div class=\"mj-column-per-100 mj-outlook-group-fix\" style=\" font-size: 0px; text-align: left; direction: ltr; display: inline-block; vertical-align: top; width: 100%; \"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align: top; padding: 0px\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"\" width=\"100%\"> <tr> <td align=\"center\" vertical-align=\"middle\" style=\" font-size: 0px; padding: 35px 0; word-break: break-word; \"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\" border-collapse: separate; line-height: 100%; \"> <tr> <td align=\"center\" bgcolor=\"#E17D1E\" role=\"presentation\" style=\" border: none; border-radius: 3px; cursor: auto; height: 50px; mso-padding-alt: 0 25px; background: #e17d1e; \" valign=\"middle\"> <a href=\" \" style=\" display: inline-block; background: #e17d1e; color: #ffffff; font-family: Montserrat, sans-serif; font-size: 11.5px; font-weight: 700; line-height: 120%; margin: 0; text-decoration: none; text-transform: uppercase; padding: 0 25px; mso-padding-alt: 0px; border-radius: 3px; \" target=\"_blank\"> </a> </td> </tr> </table> </td> </tr> </table> </td> </tr> </tbody> </table> </div>  </td> </tr> </tbody> </table> </div>   <div style=\"Margin:0px auto;max-width:570px;\"> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width:100%;\"> <tbody> <tr> <td style=\"direction:ltr;font-size:0px;padding:0px;text-align:center;vertical-align:top;\">  <div class=\"mj-column-per-100 outlook-group-fix\" style=\"font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align:top;padding:0px;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tr> <td style=\"font-size:0px;padding:30px 0px;word-break:break-word;\"> <p style=\"border-top:solid 1px #E6EAF1;font-size:1;margin:0px auto;width:100%;\"> </p>  </td> </tr> </table> </td> </tr> </tbody> </table> </div>  </td> </tr> </tbody> </table> </div>  <div style=\"Margin:0px auto;max-width:570px;\"> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width:100%;\"> <tbody> <tr> <td style=\"direction:ltr;font-size:0px;padding:0px;padding-bottom:0px;text-align:center;vertical-align:top;\">  <div class=\"mj-column-per-100 outlook-group-fix\" style=\"font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align:top;padding:0 20px;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tr> <td align=\"center\" style=\"font-size:0px;padding:0px;word-break:break-word;\"> <div style=\"font-family:Montserrat, sans-serif;font-size:11px;font-weight:400;line-height:14px;text-align:center;color:#667797;\"> Si vous rencontrez des difficultés, consultez notre <a href=\"com/faq/\" style=\"color: #EC4105; text-decoration: none;\">rubrique Aide.</a></div> </td> </tr> </table> </td> </tr> </tbody> </table> </div>  </td> </tr> </tbody> </table> </div>  <div style=\"Margin:0px auto;max-width:570px;\"> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width:100%;\"> <tbody> <tr> <td style=\"direction:ltr;font-size:0px;padding:0px;padding-top:25px;text-align:center;vertical-align:top;\">  <div class=\"mj-column-per-100 outlook-group-fix\" style=\"font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align:top;padding:0px;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tr> <td align=\"center\" style=\"font-size:0px;padding:0px;word-break:break-word;\">  <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"float:none;display:inline-table;\"> <tr> <td style=\"padding:0 5px;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"border-radius:3px;width:25px;\"> <tr> <td style=\"font-size:0;height:25px;vertical-align:middle;width:25px;\"> <a href=\"https://twitter.com/RIFFX_fr\" target=\"_blank\"><img height=\"25\" src=\"ngly.com/wp-content/themes/riffx/emails/images/reseaux-sociaux/twitter.png\" style=\"border-radius:3px;\" width=\"25\"></a></td> </tr> </table> </td> </tr> </table>  <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"float:none;display:inline-table;\"> <tr> <td style=\"padding:0 5px;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"border-radius:3px;width:25px;\"> <tr> <td style=\"font-size:0;height:25px;vertical-align:middle;width:25px;\"> <a href=\"https://www.instagram.com/riffx_fr\" target=\"_blank\"><img height=\"25\" src=\"content/themes/riffx/emails/images/reseaux-sociaux/instagram.png\" style=\"border-radius:3px;\" width=\"25\"></a></td> </tr> </table> </td> </tr> </table>  <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"float:none;display:inline-table;\"> <tr> <td style=\"padding:0 5px;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"border-radius:3px;width:25px;\"> <tr> <td style=\"font-size:0;height:25px;vertical-align:middle;width:25px;\"> <a href=\"https://www.facebook.com/riffxfr/\" target=\"_blank\"><img height=\"25\" src=\".com/wp-content/themes/riffx/emails/images/reseaux-sociaux/facebook.png\" style=\"border-radius:3px;\" width=\"25\"></a></td> </tr> </table> </td> </tr> </table>  <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"float:none;display:inline-table;\"> <tr> <td style=\"padding:0 5px;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"border-radius:3px;width:25px;\"> <tr> <td style=\"font-size:0;height:25px;vertical-align:middle;width:25px;\"> <a href=\"https://www.youtube.com/channel/UCtdWZCbMyA1YmcM-_p-eipg\" target=\"_blank\"><img height=\"25\" src=\"p-content/themes/riffx/emails/images/reseaux-sociaux/youtube.png\" style=\"border-radius:3px;\" width=\"25\"></a></td> </tr> </table> </td> </tr> </table>  </td> </tr> </table> </td> </tr> </tbody> </table> </div>  </td> </tr> </tbody> </table> </div>  <div style=\"Margin:0px auto;max-width:570px;\"> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width:100%;\"> <tbody> <tr> <td style=\"direction:ltr;font-size:0px;padding:0px;text-align:center;vertical-align:top;\">  <div class=\"mj-column-per-100 outlook-group-fix\" style=\"font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align:top;padding:0px;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tr> <td style=\"font-size:0px;padding:20px 0;word-break:break-word;\"> <p style=\"border-top:solid 1px #E6EAF1;font-size:1;margin:0px auto;width:100%;\"> </p>  </td> </tr> </table> </td> </tr> </tbody> </table> </div>  </td> </tr> </tbody> </table> </div>  <div style=\"Margin:0px auto;max-width:570px;\"> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width:100%;\"> <tbody> <tr> <td style=\"direction:ltr;font-size:0px;padding:0px;padding-bottom:20px;text-align:center;vertical-align:top;\">  <div class=\"mj-column-per-100 outlook-group-fix\" style=\"font-size:0;line-height:0;text-align:left;display:inline-block;width:100%;direction:ltr;\">  <div class=\"mj-column-per-50 outlook-group-fix\" style=\"font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:50%;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align:top;padding:0px;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tr> <td align=\"left\" style=\"font-size:0px;padding:0px;word-break:break-word;\"> <div style=\"font-family:Montserrat, sans-serif;font-size:10px;line-height:1;text-align:left;color:#8A8A8F;\"> Copyright © 2021 RIFFX</div> </td> </tr> </table> </td> </tr> </tbody> </table> </div>  <div class=\"mj-column-per-50 outlook-group-fix\" style=\"font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:50%;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align:top;padding:0px;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tr> <td align=\"right\" style=\"font-size:0px;padding:0px;word-break:break-word;\"> <table align=\"right\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"border-collapse:collapse;border-spacing:0px;\"> <tbody> <tr> <td style=\"width:64px;\"><img alt=\"logo\" height=\"auto\" src=\".com/wp-content/themes/riffx/emails/images/logo-footer-new.png\" style=\"border:0;display:block;outline:none;text-decoration:none;width:100%;\" width=\"64\"></td> </tr> </tbody> </table> </td> </tr> </table> </td> </tr> </tbody> </table> </div>  </div>  </td> </tr> </tbody> </table> </div>  <div style=\"Margin:0px auto;max-width:570px;\"> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width:100%;\"> <tbody> <tr> <td style=\"direction:ltr;font-size:0px;padding:0px;padding-bottom:20px;text-align:center;vertical-align:top;\">   <div class=\"mj-column-per-50 outlook-group-fix\" style=\"font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align:top;padding:0px;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> </table> </td> </tr> </tbody> </table> </div>  </td> </tr> </tbody> </table> </div>  <div style=\"Margin:0px auto;max-width:570px;\"> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width:100%;\"> <tbody> <tr> <td style=\"direction:ltr;font-size:0px;padding:0px;padding-bottom:20px;text-align:center;vertical-align:top;\">  <div class=\"mj-column-per-100 outlook-group-fix\" style=\"font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align:top;padding:0px;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tr> <td align=\"left\" style=\"font-size:0px;padding:0px;word-break:break-word;\"> <div style=\"font-family:Montserrat, sans-serif;font-size:10px;line-height:13px;text-align:left;color:#8A8A8F;\"> <strong>Les informations collectées sont récupérées sur la base de votre consentement que vous pouvez retirer à tout moment.</strong>Les informations seront conservées le temps nécessaire au traitement. Conformément à la loi «informatique et libertés» du 6 janvier 1978 modifiée et au «règlement européen» n ° 2016/679/UE du 27 avril 2016 (applicable depuis le 25 mai 2018) relatif à la protection des données à caractère personnel, vous bénéficiez d\'un droit d\'accès, de rectification, de portabilité et d\'effacement de vos données ou encore de limitation du traitement. Pour exercer vos droits, merci d\'adresser votre demande auprès de <a href=\"mailto:dpo-riffx@e-i.com\" style=\"color: #EC4105; text-decoration: none;\">dpo-riffx@e-i.com</a><br><br> Ce message est établi à l\'intention exclusive de son ou ses destinataires. Si vous avez reçu ce message par erreur, merci de nous avertir via notre <a href=\"https://riffx.fr/contact/\" style=\"color: #EC4105; text-decoration: none;\">formulaire de contact</a> et de détruire le message. Toute modification, édition, utilisation ou diffusion non autorisée est interdite. L\'émetteur décline toute responsabilité au titre de ce message s\'il a été modifié, déformé, falsifié, infecté par un virus ou encore édité ou diffusé sans autorisation. Pour en savoir plus sur notre politique de confidentialité, <a href=\"https://riffx.fr/politique-de-confidentialite/\" style=\"color: #EC4105; text-decoration: none;\">cliquez ici</a>. <br> <br> <strong>RIFFX by Crédit Mutuel</strong> est une marque musicale appartenant à la Caisse Fédérale de Crédit Mutuel. <br> <br> Caisse Fédérale de Crédit Mutuel et caisses affiliées, société coopérative à forme de société anonyme au capital de 5 458 531 008 euros, 4 rue Frédéric-Guillaume Raiffeisen 67913 Strasbourg cedex 9, RCS Strasbourg B 588 505 354.</div> </td> </tr> </table> </td> </tr> </tbody> </table> </div>  <div class=\"mj-column-per-50 outlook-group-fix\" style=\"font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> <tbody> <tr> <td style=\"vertical-align:top;padding:0px;\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\"> </table> </td> </tr> </tbody> </table> </div>  </td> </tr> </tbody> </table> </div>  </td> </tr> </tbody> </table> </div>  </div></body></html>",
        "plain_content": "Check out our spring line!",
        "subject": "Mon test d'envoi"
    },
    "name": "Envoi de test"
}

I passed in the json validator but i don't understand why it's not good.

Cheers

thinkingserious commented 3 years ago

@LudovicFauchet,

What does print_r($response->body()); return? For me, I get a 400 error that says "json could not be unmarshalled". Also, I get a parse error on the html_content line when running your json through a linter. I suspect there is some issue with the HTML there.

LudovicFauchet commented 3 years ago

@thinkingserious Same results for me, but my html is basic i jusst escaped quote...

LudovicFauchet commented 3 years ago

@thinkingserious did you ever try with a full page html instead of only html tag (there is only those exemple in the documentation)

JenniferMah commented 3 years ago

Hi @LudovicFauchet! I'm still seeing an error with an invalid character in your HTML content when I run your json through the validator. Can you verify that all the quotes have been escaped.

LudovicFauchet commented 3 years ago

Hello @JenniferMah i checked again it seems all the quotes have been escaped :/

LudovicFauchet commented 3 years ago

Hello , i found the problem i add to do a json_endode to works, my bad :/

I have an other question, i want to know how to change the singlesend status to draft, if the post is scheduled

Thanks in advance